The preferred method of enabling and disabling Advertising Features, including Remarketing and Advertising Reporting Features, or Advertising Personalization is to modify your property settings.
However, there may be times when you want to disable these features dynamically for a given page load or session, for example, when users have indicated they do not want their data used for the purpose of personalizing ads. You can accomplish this by modifying any version of the Analytics tracking code for which Advertising Features are available.
The following sections explain how to programmatically disable these features regardless of whether you've enabled them via your property settings or via your tracking code. The corresponding programmatic enablement instructions, also available elsewhere in our documentation, are provided here for reference. You can also control whether Advertising Features and Advertising Personalization are enabled or disabled for an app by following these instructions.
allow_ad_personalization_signals
to false
disabled all advertising features. After July 16th, 2020, setting allowAdPersonalizationSignals
to false
for Universal Analytics properties or allow_ad_personalization_signals
to false
for Google Analytics 4 properties will no longer affect the advertising reporting features turned on in your Google Analytics property. This setting will mark relevant hits with a field that tells Google Analytics to omit the associated data from Ads Personalization features.Disable with Google Tag Manager
To disable advertising features or advertising personalization when your Google Analytics tags are configured in Google Tag Manager, set the allowAdFeatures
or allowAdPersonalizationSignals
field to false in Fields to Set in your tag or settings variable.
Disable advertising personalization
Universal Analytics implementations
- Open any relevant Universal Analytics tags or Google Analytics Settings variables. If your tag uses a Google Analytics Settings variable, you only need to make this change in the settings variable unless you want to override it on a tag by tag basis.
- Under More Settings > Fields to Set, select + Add Field.
- For Field Name, enter allowAdPersonalizationSignals.
- For Value, enter false (or select a variable that returns false conditionally).
Google Analytics 4 implementations
- Open any relevant Google Analytics 4 Configuration tag.
- Under More Settings > Fields to Set, select + Add Field.
- For Field Name, enter allow_ad_personalization_signals.
- For Value, enter false (or select a variable that returns false conditionally).
Disable all advertising features
Universal Analytics implementations
- Open any relevant Universal Analytics tag. If your tag uses a Google Analytics Settings variable, you only need to make this change in the settings variable unless you want to override it on a tag-by-tag basis.
- Under More Settings > Fields to Set, select + Add Field.
- For Field Name, enter allowAdFeatures.
- For Value, enter false (or select a variable that returns false conditionally).
Google Analytics 4 implementations
- Open any relevant Google Analytics 4 Configuration tag.
- Under More Settings > Fields to Set, select + Add Field.
- For Field Name, enter allow_google_signals.
- For Value, enter false (or select a variable that returns false conditionally).
To enable Display Remarketing and the Advertising Reporting Features, modify your property settings in Analytics.
If you enabled the toggle in your property settings but have disabled Advertising features in the tag, and then you want to re-enable them (for example after consumer consent is given), you can simply cease the disablement at a tag level. This will effectively "re-enable" Advertising features for that customer.
Disable with gtag.js
You cannot disable advertising features for an Google Analytics 4 property via connected site tags if you are currently using gtag('config')
to execute the command. Disabling advertising features implemented with gtag('set')
will work with connected site tags.
If are using the config
command and want to use connected site tags for Google Analytics 4, and you want to disable advertising features for an Google Analytics 4 property programmatically (e.g., gtag('config', 'TAG_ID', { 'allow_google_signals': false });
), you need to add that code directly to the relevant web pages.
To disable only advertising personalization with gtag.js, set allow_ad_personalization_signals
to false
before any config
commands:
To disable all advertising features with gtag.js, set allow_google_signals
to false
before any config
commands:
gtag('set', 'allow_google_signals', false);
Read the developer documentation for more information, including how to disable advertising personalization only for specific products.
Enable with gtag.jsIt is not currently possible to enable Display Remarketing and the Advertising Reporting Features via code using gtag.js. If you use gtag.js and want to enable Display Remarketing and the Advertising Reporting Features, modify your property settings in Analytics.
If you enabled the toggle in your property settings but have disabled Advertising features in the tag, and then you want to re-enable them (for example after consumer consent is given), you can simply cease the disablement at a tag level. This will effectively "re-enable" Advertising features for that customer.
Disable with analytics.js
To disable only advertising personalization with analytics.js, set allowAdPersonalizationSignals
to false
:
Add ga('set', 'allowAdPersonalizationSignals', false);
after the create
command, and before the hit is sent.
To disable all advertising features with analytics.js, set allowAdFeatures
to false
:
Add ga('set', 'allowAdFeatures', false);
after the create
command, and before the hit is sent.
To enable these features for Universal Analytics, insert the highlighted line into your existing tracking code between the 'create'
and 'send'
commands, as in this example:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-XX', 'example.com');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
Disable with ga.js
To override the property settings to turn off Advertising Reporting Features:
Add _gaq.push(['_set', 'displayFeatures', false]);
after the create
command, and before the hit is sent.
If you're still using ga.js, you can enable Remarketing and Advertising Reporting Features for Standard Analytics by replacing the highlighted code in this example:
Standard tracking code
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxx-y']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
with the highlighted code in the example below:
Code modified to enable these features
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxx-y']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Disable with Measurement Protocol
If you use Measurement Protocol to send data into Google Analytics, you may flag that data as not to be used for advertising personalization. Learn more in Developer Documentation for Measurement Protocol.