Google Consent Mode

Guide to Google Consent Mode integration with the Ours Privacy CMP, including automatic integration for GTM and GA4.

Google Consent Mode

If you are not using the Ours Privacy CMP, you will typically need to wire Google Consent Mode manually so GTM/GA4 respects your cookie categories.

Below is a minimal example of how to do this:

<!-- Load GTM container as usual -->
<script
  async
  src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"
></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() {
    dataLayer.push(arguments);
  }

  // 1. Default: Set denied for analytics/ad storage
  gtag("consent", "default", {
    ad_storage: "denied",
    analytics_storage: "denied",
  });

  // 2. Normal gtag config
  gtag("js", new Date());
  gtag("config", "G-XXXXXXX");
</script>

Then, when the user consents via your CMP:

// On user acceptance
gtag("consent", "update", {
  ad_storage: "granted",
  analytics_storage: "granted",
});

This ensures Google Analytics and Ads respect user consent choices.


Note for Ours Privacy Users

If you're using the Ours Privacy CMP, you do not need to do this manually.

Our platform automatically integrates with Google Consent Mode out-of-the-box:

  • Sets initial denied state.
  • Automatically updates Google Consent Mode when users give or withdraw consent.
  • Works seamlessly with GTM, GA4, and Google Ads tags.

No extra code required.


Next Steps

How is this guide?

On this page

Google Consent Mode Integration - Ours Privacy