Measure IAB TCF GDPR consent given rate with Google analytics

07 May 2019

GDPR flag

It is important to understand the consent given rate on a website for most publishers installed a paid or free IAB CMP (Consent management platform/manager).

Consent given rate is important for publishers regarding the revenue of display ads after GDPR. Most demand partners bid the inventory based on consent signals.

Google analytics provides the Javascript API for custom event measurement. Publishers can measure the GDPR consent given rate by users with Google analytics. This article shows how to measure and gain insight into the consent given at IAB CMP.

Google Analytics Debugger

Before getting started, it is worth mentioning there is a tool for debugging: Google Analytics Debugger. It is a Chrome plugin, once installed, you are able to see the detail logs at Chrome console how the webpage communicates with Google Analytics:

google analytics debugger

Custom Event Measurement

Google analytics custom event measurement API:

ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

When the Google analytics is installed with Google tag manager, you might see the error:

Command ignored. Unknown target: undefined

This is because the tracker is unknown in your context scope, tracker can be get in this way:

var trackers = window.ga.getAll();
var tracker = trackers[0].a.data.values[":name"];

Then send custom events with the tracker:

ga(tracker + '.send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

IAB CMP API (IAB Europe’s TCF v1.0)

All the IAB certified CMP like UniConsent provide the following API to access to the choices given by a user:

window.__cmp('getPublisherConsents', null, function(result){
		console.log(result);
});

The result looks like this:

IAB CMP API

If you like to measure how many people selected yes on ‘Information storage and access’, you can do like this:

var trackers = window.ga.getAll();
var tracker = trackers[0].a.data.values[":name"];
window.__cmp('getPublisherConsents', null, function(result){
	var choice1 = result.standardPurposeConsents[1] ? 'Yes' : 'No';
	ga(tracker + '.send', 'event', 'IAB CMP', 'Consent', 'Information storage and access', choice1);
});

The API of IAB Europe’s TCF v2.0 is slightly different from v1.0. But the concept is the same.

UniConsent has built-in consent Analytics and Insight feature. You are able to see how many people give positive consent and details.

GDPR IAB CONSENT insight analytics

Reference

Let's get you started

Make your website GDPR CCPA compliant