Custom Consent Mode V2 implementation for Google Ads & GA4

A business needed a custom Consent Mode V2 implementation that respected user privacy choices while still allowing GA4 and Google Ads to receive the correct consent signals.

The challenge

The cookie banner was functioning and sending cookieless pings, but the consent state was not updating immediately after the user accepted cookies or saved preferences.

This created a tracking risk: the user could accept cookies, but GTM and Google tags would still behave as if consent had not been updated until the next page load.

In some cases, this also affected traffic-source attribution because the gclid parameter could be lost before consent was properly updated.

What I investigated

  • Cookie banner behavior
  • GTM consent state
  • GA4 and Google Ads requests
  • gcs and gcd parameters
  • ad_storage, ad_user_data and ad_personalization signals
  • EM.cookie_policy.cookies consent objects
  • gclid persistence after consent
Consent states for Google Ads and personalized advertising
Consent states for Google Ads and personalized advertising.

The solution

I adjusted the Consent Mode V2 flow so the user’s choice was passed to GTM immediately after they interacted with the cookie banner, without waiting for another page load.

  • Update the EM.cookie_policy.cookies object in real time.
  • Push a consent_update event into the dataLayer.
  • Use the consent_update event as a GTM trigger.
  • Update Consent Mode signals through GTM.
  • Separate Google Ads consent from Google Ads personalized advertising consent.
  • Validate ad_storage, ad_user_data and ad_personalization independently.
  • Confirm that gclid values are preserved after cookie acceptance and navigation.
consent_update event pushed into the dataLayer with the right values
Consent update event pushed into the dataLayer.
gcs gcd and gclid validation in network requests
GCS, GCD and GCLID validation.

Result

After the update, GTM, GA4 and Google Ads received the correct consent state at the right moment, making the tracking setup more reliable.

It improved the accuracy of Google Ads conversion and remarketing tracking while keeping the setup aligned with privacy and consent requirements.

← Back to case studies