Consentful
Guides

Google Analytics 4 and Tag Manager

Use Google Analytics 4 and Google Tag Manager with Consentful so they respect cookie consent and Google Consent Mode v2.

Updated · By , founder of The Plugins Company

Google Analytics 4 (gtag.js)

Easiest: on the Scripts tab, add https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX in the Analytics category, plus a second inline script in the same category:

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXX');

Then remove any GA snippet from your site's code. GA4 now loads only after the visitor allows analytics.

Google Tag Manager

Keep your GTM container on the page as usual — Consentful sets Consent Mode v2 defaults to denied before it loads, and sends an update when the visitor chooses. Inside GTM:

  1. Open Admin → Container settings and turn on Enable consent overview.
  2. For each Google tag, the built-in consent checks already apply.
  3. For non-Google tags (Meta, Hotjar…), set Additional consent checks to require ad_storage or analytics_storage — or move those tags into Consentful's Scripts tab instead.

Make sure Consentful loads before GTM in the page head. The platform apps place it first automatically.

Sources

On this page

Google Analytics 4 and Tag Manager | Consentful