Display Advertising

Update Your Analytics Tracking Code to Support Display Advertising

If you choose to support Display Advertising, you need to make a simple, one-line change to your Google Analytics tracking code. Once you have made this change, Google Analytics collects the information it normally does, as well as the DoubleClick cookie when that cookie is present. For more information about this cookie, visit the Google Advertising Privacy FAQ. When you make this update to your tracking code, you also need to update your privacy policy.

This modification does not impact any customizations you have previously made to your code.

The changes you need to make depend on which tracking code you’re using. See if you have Classic Analytics (ga.js) or Universal Analytics (analytics.js).
Tracking code change for Universal Analytics (analytics.js)

To implement Display Advertising features for Universal Analytics, insert the bold line into your existing tracking code between the 'create' and 'send' commands, as seen 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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-XX', 'example.com');

ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
Tracking code change for Classic Google Analytics (ga.js)

To implement Display Advertising features for Classic Google Analytics, replace the bold text in this example:

<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 bold text in the example below:

<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>

You can also generate an updated basic code snippet that includes the change by going to Admin > property > Tracking Info, and turning on the Display Advertiser Support option.

If you're using Google Tag Manager, follow these instructions to edit the Analytics tag.

Please note that if you choose to not enable this feature, there is no need to update your tracking code, and Google Analytics will continue to function as usual.