GTM Consent Mode V2 for Webflow

How to install GTM in Webflow, add a c15t cookie banner, and connect it to Consent Mode v2 and Webflow's built-in analytics.

  • A Webflow cookie banner only controls GTM tags if its choices are passed to Google Consent Mode v2; otherwise banners fail to block GTM tags, GA4/Ads cookies set before consent, tags don't fire after acceptance, and Webflow's own analytics ignores the banner.
  • One fix covers all four problems: set Consent Mode defaults BEFORE GTM loads, then pass every banner choice to both Google (gtag consent update) and Webflow (wf.allowUserTracking / wf.denyUserTracking).
  • Script order in Webflow's Head code matters: consent default/sync script first, then the c15t banner script, then the GTM snippet last. Don't load the banner through GTM, and remove any hardcoded GA4/Ads/pixel snippets elsewhere.
  • c15t is an open source banner with a standalone browser build, so it works on Webflow with a single script tag and no build step.
  • Defaults are region-based: analytics granted by default, but denied in the EEA, UK and Switzerland. Remove the first default line and the region on the second for opt-in everywhere. Ad consent stays denied; add a marketing category mapped to ad_storage, ad_user_data and ad_personalization if you run ad tags.
  • In GTM, create a Custom Event trigger named c15t_consent so blocked tags fire immediately after a visitor accepts, with no second page view needed. Set each tag's additional consent requirement and use 'Once per page' firing to prevent double fires.
  • Add a Custom HTML tag that calls wf.allowUserTracking({activate:true}) when analytics consent is granted, covering regions where the default is granted and the banner is untouched.
  • Custom code doesn't run in the Webflow Designer, so publish before testing. Verify in a private window with GTM Preview: defaults match, no _ga cookie where denied, accepting fires c15t_consent and GA4 on the same page, and wf.getUserTrackingChoice() returns allow/deny correctly.

A cookie banner on Webflow only controls GTM tags when its choices are passed to Consent Mode v2.

If you want a Webflow cookie banner that your tags respect, the banner, GTM and Webflow’s own analytics all have to read the same choice. Here’s the setup I use on my demo site, webflow.kevinleary.net, with c15t as the banner.

Why Most Webflow Banners Fail

Problem Cause
Banner doesn’t block scripts loaded through GTM The banner only blocks script tags in the page. Tags inside a GTM container never see it.
GA4 and Google Ads cookies set before consent GTM loads before a default consent state exists, so tags start with no restrictions. I see this often with Finsweet Consent Pro setups.
GA tags don’t fire after a visitor accepts The tag was blocked on page load and nothing tells GTM to try again once consent is granted.
Webflow’s analytics ignore the banner Webflow tracking has its own on and off switch that the banner never touches.

All four are fixed by the same thing: set the defaults before GTM loads, then pass every banner choice to both Google and Webflow.

Install GTM in Webflow

  1. Copy your container ID from Google Tag Manager. It looks like GTM-XXXXXXX.
  2. In Webflow, go to Site settings > Custom code > Head code.
  3. Paste the GTM snippet at the bottom of the field. The consent code in the next steps goes above it.
  4. Remove any GA4, Google Ads or pixel snippets hardcoded elsewhere on the site, so GTM is the only thing loading tags.
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');
</script>

c15t is an open source consent banner with a standalone browser build, so it works on Webflow with a single script tag and no build step. Add it to the head code, above the GTM snippet:

<script src="https://cdn.jsdelivr.net/npm/@c15t/[email protected]/dist/c15t.local.js" data-categories="measurement"></script>

The data-categories attribute sets which categories the banner asks about. My demo site only runs analytics, so it only asks about measurement.

Don’t load the banner through GTM. It needs to be on the page before the container so the consent state is ready when GTM starts.

This script is the part that matters. It goes first in the head code, above the c15t script, and does three things:

  1. Sets the Consent Mode v2 defaults before GTM loads.
  2. Sends every c15t choice to Google with a consent update, plus a dataLayer event GTM can use as a trigger.
  3. Sends the same choice to Webflow’s built-in tracking with wf.allowUserTracking() and wf.denyUserTracking().
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
(function(){
  // Defaults: analytics on, but off in the EEA, UK and Switzerland
  var eu = ['AT','BE','BG','HR','CY','CZ','DK','EE','FI','FR','DE','GR','HU','IE','IT','LV','LT','LU','MT','NL','PL','PT','RO','SK','SI','ES','SE','IS','LI','NO','GB','CH'];
  gtag('consent', 'default', {ad_storage:'denied', ad_user_data:'denied', ad_personalization:'denied', analytics_storage:'granted', wait_for_update:500});
  gtag('consent', 'default', {ad_storage:'denied', ad_user_data:'denied', ad_personalization:'denied', analytics_storage:'denied', region:eu, wait_for_update:500});

  function wfDo(fn){ if (window.wf && wf.ready) { wf.ready(fn); } }

  // Pass the visitor's c15t choice to Google and to Webflow
  var rdy = false, last;
  function sync(){
    if (!rdy || !window.c15t || !c15t.hasConsented || !c15t.hasConsented()) { return; }
    var ok = !!c15t.has('measurement');
    if (ok === last) { return; }
    var first = last === undefined;
    last = ok;
    gtag('consent', 'update', {analytics_storage: ok ? 'granted' : 'denied'});
    if (!first || rdy === 2) { dataLayer.push({event:'c15t_consent', analytics_consent: ok ? 'granted' : 'denied'}); }
    wfDo(function(){ if (ok) { wf.allowUserTracking({activate:true}); } else { wf.denyUserTracking(); } });
  }

  window.c15t = window.c15t || [];
  c15t.push(['on', 'ready', function(){ rdy = true; sync(); rdy = 2; }]);
  c15t.push(['on', 'consent', sync]);

  // Webflow tracking stays off until a choice is made
  document.addEventListener('DOMContentLoaded', function(){
    wfDo(function(){ if (wf.getUserTrackingChoice() === 'none') { wf.denyUserTracking(); } });
  });
})();
</script>

A few details worth knowing:

  • The defaults are region based. Analytics starts as granted, except in the EEA, UK and Switzerland where it starts as denied. If you want opt-in everywhere, remove the first default line and the region from the second.
  • Ad consent stays denied. If you run ad tags, add a marketing category to the banner and map it to ad_storage, ad_user_data and ad_personalization in the update call, the same way measurement maps to analytics_storage.
  • The c15t_consent event only fires when a visitor makes or changes a choice. A returning visitor’s saved choice is applied before GTM’s page load triggers run, so no extra event is needed.
  • activate: true starts Webflow tracking on the current page. Without it, tracking doesn’t begin until the next page view.

Custom code doesn’t run in the Designer, so publish the site before you test.

Categorize Tags in GTM

Consent signals only control tags that are set up to check them. In GTM, go to Admin > Container Settings, check Enable consent overview, then open the shield icon on the Tags screen to see which tags have no consent settings.

Then create one trigger: a Custom Event trigger with the event name c15t_consent. This is what lets a blocked tag fire right after a visitor accepts, without waiting for a second page view.

Tag Additional consent required Triggers
Google tag (GA4) analytics_storage Initialization (All Pages), c15t_consent
Google Ads, Meta Pixel, LinkedIn and other ad tags ad_storage All Pages, c15t_consent
Hotjar, Clarity and other analytics tags analytics_storage All Pages, c15t_consent
Webflow tracking (Custom HTML, below) analytics_storage All Pages, c15t_consent

For each tag, set the consent under Advanced Settings > Consent Settings > Require additional consent for tag to fire, and set Tag firing options to Once per page so two triggers never fire it twice.

Google’s own tags have built-in consent checks, so they can run without the additional requirement and send cookieless pings while consent is denied. I add the requirement anyway so that nothing is sent until the visitor agrees.

The last tag is a Custom HTML tag that turns on Webflow tracking wherever analytics consent is granted, which covers regions where the default is granted and the banner hasn’t been touched:

<script>
(function(){
  if (window.wf && wf.ready) {
    wf.ready(function(){ wf.allowUserTracking({activate: true}); });
  }
})();
</script>

Testing

  1. Open the published site in a private window with GTM Preview running.
  2. Before touching the banner, check the Consent tab in Preview. The four Consent Mode v2 values should match your defaults, and no _ga cookie should exist where analytics is denied.
  3. Accept in the banner. A c15t_consent event should appear, analytics_storage should switch to granted, and your GA4 tag should fire on that same page.
  4. Run wf.getUserTrackingChoice() in the console. It should return allow after accepting and deny after rejecting.

For more on how the consent types work, see my guide to Consent Mode in Google Tag Manager. Once this is in place, tracking Webflow form submissions and loading HubSpot through GTM both follow the same consent categories.