Skip to main content
Angular apps are typically single-page applications powered by the Angular Router. CookieChimp installs in 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 to src/index.html inside <head>, before Angular’s bundle is injected:
Replace YOUR_ACCOUNT_ID with your actual CookieChimp Account ID from your dashboard.

How do I handle client-side navigation?

Angular Router replaces the view without a full page reload. Listen to NavigationEnd 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+):
For an NgModule-based app, place the same logic in your AppComponent’s ngOnInit.
Wrap the CookieChimp event listeners in an Angular service so any component can subscribe:
Use it in a component:
Replace "Google Analytics" and "analytics" with the exact service and category names you configured in CookieChimp.
For all available events, see Callbacks & Events.

Troubleshooting

  • Banner shows on first load but not after navigation — make sure the NavigationEnd subscription is in your root component’s ngOnInit, 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.