Display Features

This guide describes how to use the display features plugin for analytics.js.


The display features plugin for analytics.js can be used to enable Advertising Features in Google Analytics, such as Remarketing, Demographics and Interest Reporting, and more.

Learn more about Google Analytics Advertising Features.


Enabling the display features plugin only requires adding one extra line to the JavaScript tracking snippet.

To load the plugin, add a require call and specify the displayfeatures plugin.

ga('create', 'UA-XXXXX-Y', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview');

The plugin works by sending an additional request to stats.g.doubleclick.net that is used to provide advertising features like remarketing and demographics and interest reporting in Google Analytics. The plugin also creates a new cookie named _gat that has a one minute timeout. This cookie does not store any user information, it's just used to limit the number of requests that have to be made to doubleclick.net.

The default cookie name is _gat. You can change it by setting the cookieName option when you require the plugin.

ga('require', 'displayfeatures', {cookieName: 'display_features_cookie'});

Note that the third argument is normally used to specify the script location. Since the this plugin is included in analytics.js you can simply pass undefined.

Using Multiple Trackers

To use the display features plugin with multiple trackers, prepend the require call with the tracker name, as in this example:

// create a tracker named 'foo' for property UA-XXXXX-Y
ga('create', 'UA-XXXXX-Y', {name: 'foo'});
ga('foo.require', 'displayfeatures');
ga('foo.send', 'pageview');

// create a second tracker named 'bar' for a different property UA-XXXX-Z
ga('create', 'UA-XXXXX-Z', {name: 'bar'});
ga('bar.require', 'displayfeatures');
ga('bar.send', 'pageview');

Loading the display features plugin for a named tracker will result in the tracker name being appended to the cookie name. The above example would create the cookies _gat_foo and _gat_bar.

Disabling display features

Since display features can be enabled through your Google Analytics admin settings, there may be cases where you need to disable it programmatically.

To disable all display features functionality, set the display features task to not run:

ga('create', 'UA-XXXXX-Y', 'auto');
ga('set', 'displayFeaturesTask', null);
ga('send', 'pageview');

Note that in the above code the display features plugin isn't required because display features has been turned on in Google Analytics.