Stay organized with collections
Save and categorize content based on your preferences.
This page is for developers who maintain their own consent solution on their
website and want to integrate consent mode. For an introduction to consent mode,
read Consent mode overview. If you use a Consent Management Platform (CMP)
to obtain user consent, learn more about how to set up consent mode with a CMP.
You can implement consent mode in a basic or advanced way. Check your company's
guidelines to pick an implementation method and which defaults to set. Learn
more about basic versus advanced consent mode.
Before you begin
Take the following into consideration before implementing consent mode:
If you use Tag Manager and want to maintain your own banner, the recommended
approach is loading your banner through the Tag Manager container. To do so,
you need to create a consent mode template. Alternatively, you can use a
consent mode template from the Community Template Gallery.
If you use gtag.js, make sure you have installed the Google tag on every
page of your website. The consent mode code gets added to each page of your
website.
As a part of Google's ongoing commitment to a privacy-centric digital
advertising ecosystem, we are strengthening the enforcement of our EU user
consent policy.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-19 UTC."],[[["\u003cp\u003eThis guide explains how to integrate Google's consent mode for developers managing their own website consent solution.\u003c/p\u003e\n"],["\u003cp\u003eConsent mode allows you to control data collection based on user consent for advertising and analytics purposes.\u003c/p\u003e\n"],["\u003cp\u003eYou need to set the default consent state and update it based on user interactions with your consent settings.\u003c/p\u003e\n"],["\u003cp\u003eConsent mode was recently updated and now includes additional parameters for advertising user data and personalization.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers using legacy tags are encouraged to update to gtag.js or Google Tag Manager for better privacy controls.\u003c/p\u003e\n"]]],["Developers implementing their own consent solution should set up consent mode by first defining the default consent state before user interaction. They should then update the consent state based on user choices, ensuring updates are tracked before any page transitions. Consent mode has been updated to include `ad_user_data` and `ad_personalization` parameters. Users with older consent mode versions need to upgrade to v2. Legacy tags should be updated to gtag.js or Google Tag Manager.\n"],null,["\u003e This page is for developers who maintain their own consent solution on their\n\u003e website and want to integrate consent mode. For an introduction to consent mode,\n\u003e read [Consent mode overview](/tag-platform/devguides/privacy#consent_mode_overview). If you use a Consent Management Platform (CMP)\n\u003e to obtain user consent, learn more about [how to set up consent mode with a CMP](https://support.google.com/tagmanager/answer/14009343#web-consent).\n\nYou can implement consent mode in a basic or advanced way. Check your company's\nguidelines to pick an implementation method and which defaults to set. Learn\nmore about [basic versus advanced consent mode](/tag-platform/security/concepts/consent-mode#basic-vs-advanced).\n|\n| **Important** : Consent mode was updated in November, 2023 and\n| now contains two additional parameters. If you already use consent mode,\n| [upgrade to consent mode v2](#upgrade-consent-v2).\n|\n|\nLearn more about [Updates to consent mode for traffic in European Economic Area (EEA)](https://support.google.com/tagmanager/answer/13695607). \nAdvanced consent mode Basic consent mode\n\nBefore you begin\n\nTake the following into consideration before implementing consent mode:\n\n- If you use Tag Manager and want to maintain your own banner, the recommended\n approach is loading your banner through the Tag Manager container. To do so,\n you need to [create a consent mode template](https://developers.google.com/tag-platform/tag-manager/templates/consent-apis). Alternatively, you can use a\n consent mode template from the [Community Template Gallery](https://tagmanager.google.com/gallery/#/?filter=consent&page=1).\n\n- If you use gtag.js, make sure you have installed the Google tag on every\n page of your website. The consent mode code gets added to each page of your\n website.\n\nSet up consent mode To set up consent mode, you need to:\n\n1. Before a user grants consent: [Set the default\n consent state](#default-consent).\n2. [Update the consent state](#update-consent) based on the user interaction with your consent settings.\n\n\u003cbr /\u003e\n\n|\n| **Important** : Make sure that consent updates are tracked on the\n| page where they occur, before any page transition.\n|\n|\n| The Google tag takes actions (e.g. writing cookies, sending events) in\n| response to the command to ensure future events will include the full\n| measurement data.\n\nUpgrade to consent mode v2\n\nAs a part of Google's ongoing commitment to a privacy-centric digital\nadvertising ecosystem, we are strengthening the enforcement of our [EU user\nconsent policy](https://www.google.com/about/company/user-consent-policy/).\n\nLearn more about Google's [Updates to consent mode for traffic in European\nEconomic Area (EEA)](https://support.google.com/tagmanager/answer/13695607).\n\nConsent mode users need to send two new parameters in addition to `ad_storage`\nand `analytics_storage`:\n\n| Field Name | Allowed Values | Description |\n|------------------------|--------------------------|----------------------------------------------------------------------|\n| ` ad_user_data ` | ` 'granted' | 'denied' ` | Sets consent for sending user data related to advertising to Google. |\n| ` ad_personalization ` | ` 'granted' | 'denied' ` | Sets consent for personalized advertising. |\n\nNext steps\n\n- [Verify consent mode works](/tag-platform/devguides/consent-debugging#start-debugging)\n\nLegacy tag controls\n\nIf you use legacy tags, such as ga.js, analytics.js, or conversion.js, update to\ngtag.js or Google Tag Manager.\n\nTo learn more about other legacy tag's privacy controls, see the following\ndocumentation:\n\n- [Google Analytics](https://support.google.com/analytics/answer/9019185)\n- [Google Ads](https://support.google.com/google-ads/answer/9606827)\n- [Campaign Manager](https://support.google.com/campaignmanager/topic/6228828)\n\nRelated links\n\n- [Tag Manager consent APIs](/tag-platform/tag-manager/templates/consent-apis)\n- [Google tag consent APIs](/tag-platform/gtagjs/reference)\n- [Create a consent mode template](https://developers.google.com/tag-platform/tag-manager/templates/consent-apis)\n- [Community Template Gallery](https://tagmanager.google.com/gallery/#/?filter=consent&page=1)\n- [Tag consent configuration](https://support.google.com/tagmanager/answer/10718549)"]]