Skip to content

Framework · Install guide

Cookie consent for SvelteKit

Updated

Put the Kiescy script in src/app.html above %sveltekit.head%, so it's in every page's HTML and runs first.

Setup time
About 10 minutes
Coding
One line in your layout
Laws covered
GDPR, UK GDPR, CCPA, DPDP
Google Consent Mode v2
Built in, basic or advanced

Set up cookie consent on SvelteKit in 3 steps

  1. Create a free accountAdd your website. Kiescy scans it and finds the trackers that need consent.
  2. Paste one script into SvelteKitYour banner appears and starts holding back trackers until visitors choose.
  3. Check it worksOpen your site in a private window and run the free check to confirm nothing loads early.

Why SvelteKit sites need cookie consent

SvelteKit sites often start analytics in +layout.svelte on mount. For EU visitors that has to wait until they agree.

Your options on SvelteKit

ApproachGood forWatch out for
A Svelte cookie componentUI onlyCan't hold back scripts loaded before it mounts
Kiescy in app.htmlAny SvelteKit appStart analytics from onChange

Add your privacy policy

Put the embed where your privacy policy should appear, or link straight to your hosted policy URL from the footer:

Policy page
<div data-kiescy-doc="privacy"></div>
<script src="https://script.kiescy.com/embed/policy/YOUR_SITE_KEY.js" async></script>

Check that it works

Open your site in a private window: the banner should appear for a first-time visitor. Then run the free privacy check, which opens your site as a new EU visitor and lists anything that still loads before consent.

Kiescy's monitoring repeats that check on a schedule and emails you if a new script starts tracking before consent.

What your SvelteKit visitors see

Kiescy detects where each visitor is and shows the version their law requires, so you don't have to choose between the strictest banner for everyone and no banner at all.

GoodEU, UK, India and other opt-in regions: an opt-in banner. Analytics, ad pixels and embeds wait until the visitor agrees; Reject is as easy as Accept. Banner text: We value your privacy. We use cookies to run this site and, with your permission, to measure visits and show relevant ads. Buttons: Accept all, Reject all, Customise.
GoodCalifornia and other US states: an opt-out notice with a "Do Not Sell or Share" link, and Global Privacy Control honoured automatically. Banner text: Your privacy choices. We share some data with advertising partners. You can opt out at any time. Buttons: Do Not Sell or Share My Personal Information, OK.

Trackers SvelteKit sites usually load

These are the tools that most often need consent on SvelteKit sites, and how Kiescy treats them. Run a cookie scan to see exactly what yours loads.

ToolCategoryWhat happens
GA4 / Plausible / FathomAnalyticsCookieless tools may not need consent; GA4 does
PostHogAnalyticsOpt in after consent

Troubleshooting

The banner doesn't show with prerendered pages

Check the build output includes the script in each page's head; app.html is the template for prerendered pages too.

Compliance checklist for SvelteKit

  • A consent banner that blocks non-essential trackers until the visitor agrees (opt-in for the EU, UK and India).
  • A "Do Not Sell or Share" option for California visitors, and Global Privacy Control honored.
  • A privacy policy that names the tools above, linked from every page.
  • A cookie policy listing the cookies your scan finds.
  • A way for people to request, correct or delete their data.
  • Records of each consent choice, kept as proof.
  • A "Cookie settings" link calling window.pira.open().

Guides for SvelteKit site owners

Questions

Does it work with Svelte 5?

Yes. It's independent of the Svelte version.

Does it work with adapter-static?

Yes. The script is part of the generated HTML.

Official SvelteKit documentation

Menus move. If a step above doesn't match what you see, SvelteKit's own docs show the current way to add code.

Get compliant this afternoon, not this quarter.

Set up your policies, banner and request form in one place. Free while Kiescy is in early access.