Add a TermsFeed Privacy Consent cookie banner that keeps Google Analytics 4 cookies off until the visitor accepts, in 5 steps and about 15 minutes. The ePrivacy Directive and the General Data Protection Regulation (GDPR) require consent before optional cookies are set. At the end, Privacy Consent asks each visitor and records every answer.

Each step names the result you see and links the full page for that stage. Use this page for a first working setup, then complete the Go-Live Checklist before you rely on it.

What you need before starting the quickstart

You need a TermsFeed account and access to the head of your website templates, or to the head code field of your website platform. You need your Google Analytics 4 Measurement ID too, which starts with G- and sits in Google Analytics under Admin, Data streams, and your web stream.

The create form asks for the website and the company, and the result holds your snippet.

  1. Open "Your consent banners" in the TermsFeed app and select Add a consent banner.
  2. Answer "What is your website name?" and "What is your website URL?".
  3. Answer "Are you a business or an individual?".
  4. Set "Where are you based?" to the country and state of your company. The form starts on the United States and California, so change both if your company is elsewhere.
  5. Submit the form. The Overview page of the new consent banner opens under the heading "Your consent banner".

The company location decides where the consent banner must ask first under the Standard consent logic. Read why each field matters in Create Your First TermsFeed Privacy Consent Banner.

Step 2: Paste the snippet in the head of every page (about 3 minutes)

Select Copy under "Install link" on the Overview page, then paste the snippet before </head> in the template every page shares, or into the head code field of your platform. The snippet looks like this, with your own token in place of YOUR_TOKEN.

<!-- Privacy Consent by TermsFeed (https://www.termsfeed.com) -->
<script type="text/javascript" src="https://cdn.termsfeedtag.com/plugins/pc/v1/YOUR_TOKEN/plugin.js" async></script>
<!-- End Privacy Consent by TermsFeed (https://www.termsfeed.com) -->

Keep the address and the async attribute exactly as copied. Publish the change and open your website in a private window with the Network tab of DevTools filtered on termsfeedtag. A plugin.js request appears, and the consent banner shows at the bottom of the page, because a new consent banner starts on the Strict consent logic, which asks every visitor. Find where the head code goes on Shopify, WordPress, Wix, Squarespace, Webflow, and other platforms in Install TermsFeed Privacy Consent on Your Platform.

Step 3: Add Google Analytics 4 from its template (about 5 minutes)

A vendor is a tool Privacy Consent controls by the answer the visitor gives, and the template writes its code from your Measurement ID.

  1. Select Vendors in the menu of the consent banner, then Add a vendor.
  2. Select Google Analytics 4 under "Popular" in the template picker.
  3. Enter your Measurement ID in "Measurement ID".
  4. Select Add Google Analytics 4. The Vendors page lists the vendor under "Active", with "Google Analytics 4 template" under its name.

The template runs Advanced Consent Mode. The Google tag loads on every page view in the denied state, sends cookieless requests, and does not set a cookie before consent. For a tag that sends nothing until consent, add Google Analytics 4 as a custom vendor with its code in an on-accept vendor tag instead. Compare the 2 paths in Add Google Analytics 4.

Step 4: Remove the old Google Analytics snippet from your website (about 2 minutes)

Delete the Google Analytics 4 snippet from your templates, plugins, and tag manager, because Privacy Consent does not block code that stays in the page. Look in the header template of your theme, in plugins that add Google Analytics (Site Kit by Google, MonsterInsights), and in any Google Tag Manager container. Delete any Consent Mode code pasted by hand as well, because the template sends those commands itself.

View the page source of your website and search for gtag/js. The search does not find a match, because Privacy Consent adds the template code after the page loads and the source shows only what your server sends. Find the other places a tracking snippet hides in Fix Tracking Before Consent.

Step 5: Verify that the Google Analytics 4 cookies stay off until the visitor accepts (about 2 minutes)

Use private windows, because a saved answer hides the consent banner on reload. Close every private window first: private windows share storage while any is open, and a browser keeps the settings for up to 1 hour.

  1. Open a new private window, open DevTools, select the Network tab, and type google-analytics.com in the filter box.
  2. Load your website. The consent banner appears, and each collect request carries gcs=G100 in its address, which means consent is denied.
  3. Open the Application tab and expand Cookies. No _ga cookie appears.
  4. Click I Agree and reload the page. The collect requests now carry gcs=G111, and the _ga cookie appears.
  5. Select Consent log in the menu of the consent banner. The "Current month" view lists your answer with the event "Accept All".
  6. Close every private window, open a new one, load your website, click I Decline, and reload. The collect requests still carry gcs=G100, and no _ga cookie appears.

With a custom vendor in place of the template, the Network tab does not list a google-analytics.com request before I Agree. Run the full set of checks in Check That Your TermsFeed Privacy Consent Installation Works.

What your website does after the quickstart

Your website now shows the consent banner to every visitor, keeps Google Analytics 4 cookies off until the visitor accepts, and records each answer in the consent log. A visitor who clicks I Decline keeps that answer in the browser for later visits, and Google Analytics 4 does not set a cookie for that visitor.

Every other script that sets cookies or sends data about visitors needs its own vendor before launch. Add them with Vendor Recipes, then run the go-live checks before you announce the change.