This page is for developers that 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.
Set up consent modeTo set up consent mode, you need to:
- Before a user grants consent: Set the default consent state.
- Update the consent state based on the user interaction with your consent settings.
Upgrade to consent mode v2
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.
Learn more about Google's Updates to consent mode for traffic in European Economic Area (EEA).
Consent mode users need to send two new parameters in addition to
'granted' | 'denied'
|Sets consent for sending user data related to advertising to Google.
'granted' | 'denied'
|Sets consent for personalized advertising.
Legacy tag controls
If you use legacy tags, such as ga.js, analytics.js, or conversion.js, update to gtag.js or Google Tag Manager.
To learn more about other legacy tag's privacy controls, see the following documentation:
- Tag Manager consent APIs
- Google tag consent APIs
- Create a consent mode template
- Community Template Gallery
- Tag consent configuration