Example: Custom purpose for Google Analytics

With IAB's recent changes to the consent framework for GDPR, Sortable is transitioning publishers using our hosted CMP to a hosted Quantcast CMP. This and other articles will be updated in coming weeks to reflect these changes.

An example of delaying the loading of Google Analytics until the user to consents to a custom purpose.

Note: You may not need to gather consent for Google Analytics if you are not collecting User IDs or other pseudonymous identifiers.  We found this article helpful in explaining.

Configuring the custom purpose

This is an example of the configuration you'd provide to your account manager:

ID6ID is chosen to not collide with any other custom purpose used on your site
TitleGoogle AnalyticsThe title you wish to display to the user

Allow Google Analytics to collect data and use cookies for the measurement of your use of content.
See Google Analytics terms for more details: https://www.google.com/analytics/terms/us.html

The description you wish to show 

Integrate on the page

The following code delays loading until the CMP has loaded and had prompted the user. See the Google documentation for more details.

window.deployads = window.deployads || [];
// Check that the custom purpose has been accepted
window.deployads.push(function() {
  function doCustomWork() {
    // TODO: load google analytics tag here
  if (deployads.__cmp) {
    deployads.__cmp('getPublisherConsents', null, function(result){
      if (!result.gdprApplies || result.customPurposes[6]) {
        // If GDPR does not apply to this user or
        // GDPR does apply and the user has accepted the custom purpose
  } else {
    // GDPR does not apply to this user