SvelteKit uses client-side navigation by default. 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.
app.html and reinitializes on every navigation via the afterNavigate lifecycle hook.
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/app.html inside <head>, before %sveltekit.head% and any other tags so it loads first:
How do I handle client-side navigation?
SvelteKit transitions between pages without a full reload. UseafterNavigate in your root layout to re-inject the CookieChimp script on every navigation — this triggers a rescan of the newly mounted route’s DOM. The static <script> tag in app.html handles the first page load, so we skip the initial afterNavigate call.
The
browser check guards against SSR — document and window don’t exist on the server, so any DOM access must be wrapped.How do I check consent status in code?
Wrap the CookieChimp events in a Svelte store 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
afterNavigateis called from your root+layout.svelte, not from a nested layout. window is not defined/document is not definederrors — wrap any DOM orwindowaccess in abrowsercheck from$app/environment.
- 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.