Allow and block advertising features in Google Analytics – News Couple

Allow and block advertising features in Google Analytics

After writing another customTask Article on how to respect client-side opt-out with Google Analytics and Google Tag Manager, the core analytics.js library has been improved with a new field that makes it a lot easier. field allowAdFeatures, also allows you to Allow or block DoubleClick request that is triggered when advertising features are enabled.

In this very short article, I will quickly show you what the field does and why it is useful.


Simmer . Newsletter

Subscribe to the Simmer newsletter to get the latest news and content from Simo Ahava right in your inbox!

Advertising Features

If you go to the Google Analytics property settings, you can find the relevant switches under Tracking information -> Data collection.

When these two toggles are enabled, the results collected for that website on your site will automatically send the ad result to the DoubleClick endpoint as well. In other words, the analytics.js The library downloaded by setting up analytics on your site (published via Universal Analytics, gtag.js or Google Tag Manager snippets) will be automatically equipped with the tools to perform this redirect. If you want to verify that it is working, you should see the following in the output of the Google Analytics Debugger in the console:

DoubleClick request

An alternative way to spread this feature is to upload a file displayfeatures Plugin if you are using analytics.js:

ga('create', 'UA-12345-1');
ga('require', 'displayfeatures');
ga('send', 'pageview');

The require It does the same thing as toggling the property setting. The difference is that you now have the option to control the loading of this plugin or not.

The third way to deploy this feature is to use the respective tag setting in Google Tag Manager:

GTME Setup

All of these settings do the same thing – once a result is sent to Google Analytics, a request is sent to the DoubleClick server as well, which contains information about the user (such as the client ID) and the website (property ID). This request is used to generate demographics and interests reports and to create remarketing audiences.

the new allowAdFeatures field

But what if you want to conditionally prevent the request from being sent? Under the GDPR, this might be a very good idea. If the visitor does not explicitly participate in the collection of their visit data in DoubleClick’s servers, you may want to block the request from being sent.

In a previous article, I recommended using customTask For this. However, because of how displayFeaturesTask I can not To control the setup of the plugin / Google Tag Manager, it turned out to be an ineffective solution.

Fortunately, Google released a file allowAdFeatures , which you can use to conditionally block a DoubleClick request regardless on how to create it.

Note that the field cannot be used construction Collect advertising features. You still need to 1) enable the respective GA property settings first, or 2) upload a file displayfeatures plugin, or 3) toggle the respective setting in your Google Tag Manager tags. This field is simply either Allow Traffic request, or lumps He. She.

The hypothetical field value true, so if you don’t add the field to your setup, the ad features will run regularly, sending a DoubleClick request if needed. If you set the field to false, the DoubleClick request will be unconditionally blocked on the current page.

To use the domain in analytics.js, you can do something like this:

ga('create', 'UA-12345-1');
if (checkUserConsent() === 'NO') 
  ga('set', 'allowAdFeatures', false);

ga('send', 'pageview');

In the above example, if the method checkUserConsent() returns the value 'NO'ad features of this tracker will be blocked.

To use this in Google Tag Manager you have to go to More settings -> Fields to be set, and add a new field with:

field name: allowAdFeatures
Values: correct error

Of course, it’s easier to use a variable that checks for user consent, and then make sure the variable is returned as well true or false, depending on whether you want to allow or block the DoubleClick request, respectively.

Allow advertising features


I hope all of this makes sense. The point of allowAdFeatures It gives you complete control on the client side as to whether or not a DoubleClick request should be executed. Due to the flexibility allowAdFeatures I personally use the following setup:

  1. Toggle your Google Analytics Remarketing and Advertising Features Settings / Site Settings / Tracking Information / Data Collection.

  2. Confirm your ad features selections handicapped In Google Tag Manager tags.

  3. use the allowAdFeatures To conditionally block advertising features if the visitor does not subscribe.

This is, in my experience, the easiest solution to manage.

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button