Angular apps are typically single-page applications powered by the Angular Router. CookieChimp installs inDocumentation Index
Fetch the complete documentation index at: https://docs.cookiechimp.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
index.html and reinitializes on route changes via the Router event stream.
Before you start: have your CookieChimp Account ID ready (replace
YOUR_ACCOUNT_ID in the snippets below). If you're testing on localhost, add localhost to Additional Domains in your Account Settings — otherwise the banner won't show locally.How do I load the CookieChimp script?
Add the script tag tosrc/index.html inside <head>, before Angular’s bundle is injected:
How do I handle client-side navigation?
Angular Router replaces the view without a full page reload. Listen toNavigationEnd events and re-inject the CookieChimp script so it rescans the new route’s DOM. The static <script> tag in index.html handles the first load, so we skip the initial event.
If you’re using a standalone component root (Angular 17+):
NgModule-based app, place the same logic in your AppComponent’s ngOnInit.
How do I check consent status in code?
Wrap the CookieChimp event listeners in an Angular service so any component can subscribe:Replace
"Google Analytics" and "analytics" with the exact service and category names you configured in CookieChimp.Troubleshooting
- Banner shows on first load but not after navigation — make sure the
NavigationEndsubscription is in your root component’sngOnInit, not a lazy-loaded module. - Change detection issues with consent state — wrap state updates inside
NgZone.run()(shown above) so Angular re-renders.
- Banner doesn't appear at all — confirm
localhost(or your domain) is in Additional Domains in Account Settings. - Enable Debug mode in the CookieChimp dashboard and check the browser console for logs.