Integrations
Google Analytics 4Google Analytics 4
preset documentationDocumentation

CookiePilot GA4 preset: analytics_storage, _ga and pre-consent testing

Set Google Analytics 4 as analytics and start measurement only after consent. CookiePilot keeps analytics_storage denied before the user's choice and helps separate cookieless pings from tracking cookies.

Overview

Set Google Analytics 4 as analytics and start measurement only after consent. CookiePilot keeps analytics_storage denied before the user's choice and helps separate cookieless pings from tracking cookies.

Category

analytics.

Code

analytics_storage denied before consent.

Result

Google cookieless pings with denied are not the same as tracking cookies.

Consent behaviour

No _ga before consent.

gcd shows analytics denied.

After Accept, analytics is granted.

Conversion events are not duplicated in GTM.

Setup steps

Make the GA4 tag consent-aware in GTM or gtag.

Do not write _ga before analytics granted.

After Accept, check g/collect and the dataLayer update.

Example snippet

Example snippet

Example snippet
<!-- GA4 should load after Consent Mode default is already set by CookiePilot. -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', {
  anonymize_ip: true
});
</script>

<!-- Test before consent: no _ga cookie should be written. -->

Test checklist

No _ga before consent.

gcd shows analytics denied.

After Accept, analytics is granted.

Conversion events are not duplicated in GTM.

Setup steps

  1. 1Make the GA4 tag consent-aware in GTM or gtag.
  2. 2Do not write _ga before analytics granted.
  3. 3After Accept, check g/collect and the dataLayer update.

Test checklist

  • No _ga before consent.
  • gcd shows analytics denied.
  • After Accept, analytics is granted.
  • Conversion events are not duplicated in GTM.

FAQ

Is this legal advice?

No. It is an implementation guide. For unusual data flows, confirm the setup with your legal or privacy team.

Does CookiePilot block every script automatically?

CookiePilot supports autoblocking and Consent Mode. Trackers hardcoded before the CMP still need to be moved behind the stub or into GTM Consent Initialization.

Related integrations

See the setups that most often appear together with this integration.

Ready to configure it?

Start CookiePilot, choose the right integration and verify that tags wait for user consent before they run.