How to Add a Cookie Banner to a Site Built with Bolt, v0 or Cursor

TL;DR We asked Bolt and v0 to add Google Analytics to the same small site. Both did, and both load it on every page before anyone has agreed. Here is the one prompt that fixes it in Bolt, v0, Cursor and similar tools, where the script ends up in each framework, and how to check the result.

We gave Bolt and v0 the same request: build a one-page site for a small bakery and add Google Analytics. Both delivered a good-looking page within minutes. Both also set up Google Analytics to load on every page, for every visitor, before anyone had been asked anything.

That is the default in AI-built sites, and in the EU, the UK and Norway it is the wrong order. This guide shows what the tools generate, one prompt that fixes it in all of them, and how to check the result.

What Bolt and v0 did with Google Analytics

Neither tool pasted a tag into an HTML file, which is what most older guides assume.

  • Bolt built the site with Astro and connected Google Analytics to a measurement setting, loaded on the page.
  • v0 built a Next.js app, asked for a GOOGLE_ANALYTICS_MEASUREMENT_ID variable in its settings, and loads the Google Analytics tag on every page once the variable is set.

Lovable did the same: the ID in an environment variable, the tag injected on every page. It is tidy, and none of it waits for consent.

Step 1: Add the site to Consentify

Publish the site first so you have its address, then create a free Consentify account and add that address as a domain. The script only loads on domains you have added, so if you connect your own domain later, add it too.

Step 2: Paste this prompt into the tool

In the install step, choose AI builder (Lovable, Bolt, v0). The dashboard gives you this prompt with your own script tag filled in. You can also copy it from here and replace YOUR_TOKEN:

Add the Consentify cookie consent script to this site. Put this exact script tag as the very first element inside <head>, so it is rendered on every page before any other script. Use the root HTML template or root layout (for example index.html, app/layout.tsx or the root route), and keep it as a plain script tag with the async attribute:

<script async src="https://www.consentify.app/api/gateway?token=YOUR_TOKEN"></script>

Then remove all Google Analytics, Google Tag Manager, Meta Pixel, Hotjar, LinkedIn, TikTok and other tracking or advertising code from the project, including environment variables and server functions that only exist for them. Consentify will load those tools after the visitor has agreed.

Finally, add a button with id="revoke-consent-btn" and the text "Cookie settings" to the footer, so visitors can change their choice later.

It works the same in Bolt, v0, Cursor, Windsurf or Claude Code, because it describes the goal and the place rather than one framework's file. Removing the tracking code matters as much as adding the script. A tag the AI added earlier keeps firing before consent, banner or not.

Where the script ends up

You do not need to edit anything yourself, but it helps to know what to look for when you check the AI's work:

  • Astro (Bolt): in the <head> of the main layout, usually src/layouts/Layout.astro. Astro leaves a script with the async attribute as it is, so it is not bundled or delayed. See Astro's docs on scripts.
  • Next.js (v0): in the root layout, app/layout.tsx. Our Next.js guide covers the details.
  • Vite and React: first inside <head> in index.html.
  • Cursor and other editors: wherever your own project's root template is. The prompt tells the AI to find it.

Publish the site again when the AI is done.

Step 3: Add your tracking IDs in Consentify

Google Analytics is now gone from the code, so add it back the right way. In the Consentify dashboard, open Integrations and paste your measurement ID. Do the same for the Meta Pixel or anything else the prompt removed. Each tool now loads only after the visitor has accepted that category. You can also delete the analytics environment variable from the tool's settings, since nothing reads it any more.

Step 4: Check the result

Open the published site in a private window. The banner should appear, and nothing should be tracking yet. Then run the address through the free GDPR scan, which loads the page as a new visitor and lists everything that starts before consent. If it still finds Google Analytics, the AI missed a copy of the tag. Paste the scan result into the tool and ask it to remove what is listed.

While you are at it, look for Google Fonts in the scan. AI-built sites often load fonts from Google, which sends every visitor's IP address there. Our post on Google Fonts and GDPR has the fix, and our checklist of 7 things AI forgets when it builds your website covers the rest.

Free scan, no account

Does any of this apply to your site?

Find out in ten seconds. The scan shows which trackers fire before your visitors have agreed to anything.

  • Results in about 10 seconds
  • No account needed
  • Shareable report link

Frequently asked questions

Does this work for Cursor and Claude Code too?

Yes. They edit your own project rather than generating a hosted site, but the prompt describes what to do, not which file to open, so the AI finds the right place in whatever framework you use.

Why remove Google Analytics from the code instead of keeping it?

A tag in the code runs as soon as the page loads, before the banner has asked anything. Added through Consentify instead, the same tag is injected only after the visitor accepts analytics.

Can I just ask the AI to build a cookie banner?

You can, and it will look right. The hard part is making every tag wait for it, keeping a cookie declaration current and storing proof of consent. A generated banner usually does none of that.

The scan still shows Google Analytics. What now?

The AI left a copy somewhere, often in a component or a second layout. Paste the scan result into the tool and ask it to remove every remaining reference to gtag, googletagmanager.com and the measurement ID.

Free forever, no credit card

Get your cookie banner live in 5 minutes

Paste one script tag into your site and you're covered. No plugin to install, no code to write, nothing to pay.

  • 1 domain
  • 5,000 pageviews/mo
  • All integrations
  • GDPR, CCPA and ePrivacy
Start for free

No credit card. Free forever.

Compare plans
Written by Consentify
Helping you stay GDPR compliant, one banner at a time.