IAB Transparency and Consent Framework Integration

Integrating Piwik PRO Consent Manager with IAB Transparency and Consent Framework allows you to align with IAB standards for collecting and processing user data. The IAB standards require from a data collector (you) to create a cookie under the consensu.org domain for each website visitor. This integration makes the cookie creation possible.

To integrate, you’ll need to create a trigger on an event, variable, and custom tag. Optionally, you’ll be able to create the custom IAB purposes mapping.

First, we need to capture a moment when a visitor consents for using cookies. It happens when a visitor clicks Agree to all or Save choices on the consent form. At this moment, a data layer event called stg.consentsWereSent is being dispatched. Using this data, we can create a trigger.

To create a trigger on a send consent, follow these steps:

  1. Go to Menu > Tag Manager.
  2. Navigate to Triggers.
  3. Click + Create new trigger.
  4. Name the trigger and click Save.
  5. Select the Event type of an event for a trigger (on small-size screens click the drop-down menu).
  6. In Data layer event settings, set Event name equals stg.consentsWereSent.
  7. Click Save.

Creating a tag for integration

Now, we need to create a tag, that will make the integration work.

To create a tag, follow these steps:

  1. Go to Menu > Tag Manager.
  2. Click + Create new tag.
  3. Name the tag. Use any name you want to.
  4. Pick Custom asynchronous tag template and click Save.
  5. In the Tag HTML code, paste the following script:
  6.    <script>
            var INFORMATION_STORAGE_AND_ACCESS = 1;
            var PERSONALISATION =  2;
            var AD_SELECTION_DELIVERY_REPORTING = 3;
            var CONTENT_SELECTION_DELIVERY_REPOTING = 4;
            var MEASUREMENT = 5;
    
            var consent,
                queryString = '',
                newConsents = {{ Consents }} && {{ Consents }}.current_state,
                consentFormLanguage = {{ Consents }} && {{ Consents }}.consent_form_language;
    
            var iabDefaultMap = {
                analytics: [
                    CONTENT_SELECTION_DELIVERY_REPOTING,
                    MEASUREMENT
                ],
                ab_testing_and_personalization: [
                    INFORMATION_STORAGE_AND_ACCESS,
                    PERSONALISATION
                ],
                conversion_tracking: [],
                marketing_automation: [],
                remarketing: [AD_SELECTION_DELIVERY_REPORTING],
                user_feedback: []
            }
    
            var iabMap = {{ Custom IAB purposes map }} || iabDefaultMap;
    
            for (consent in newConsents) {
                if (newConsents.hasOwnProperty(consent)) {
                queryString += 'consents[' + consent + ']=' + newConsents[consent] + '&';
                }
            }
    
            for (mapItem in iabMap) {
                if (iabMap.hasOwnProperty(mapItem)) {
                queryString += 'map[' + mapItem + ']=[' + iabMap[mapItem].join() + ']&';
                }
            }
    
            queryString += 'language=' + consentFormLanguage;
    
            var pixel = document.createElement('img');
            pixel.setAttribute('height', '1');
            pixel.setAttribute('width', '1');
            pixel.setAttribute('style', 'display:none');
            pixel.setAttribute('src', '//iab.piwikpro.mgr.consensu.org/iab?' + queryString);
    
            var insertAfter = document.getElementsByTagName('body')[0];
            insertAfter.appendChild(pixel);
        </script>
    
  7. Make sure the Tag type is set to Does not require consent.
  8. In Tag triggers, select + Existing trigger and pick the trigger you’ve already created and click OK.
  9. When done, click Save for a tag.
  10. Publish the tag.

With this setup, the IAB Transparency and Consent Framework will integrate with Piwik PRO Consent Manager. Each time, your website visitor makes a decision about using their data, the tag will send this information to the consensu.org domain and you’ll keep up with IAB standards.

By default, the IAB Transparency and Consent Framework uses the default IAB purposes mapping. Yet, if you want to configure it in another way, you’ll need to set up the custom IAB purposes mapping.

About the custom IAB purposes mapping

The IAB defines purposes as individually-consentable data uses. There are five different purposes supported by IAB (the number in square brackets is the corresponding purpose number):

  • Information storage and access [1]
  • Personalization [2]
  • Ad selection, delivery, reporting [3]
  • Content selection, delivery, reporting [4]
  • Measurement [5]

The default map looks like this:

Piwik PRO consent type IAB purpose
Analytics Content selection, delivery, reporting
Measurement
A/B testing and Personalization Information storage and access
Personalization
Conversion tracking
Marketing automation
Remarketing Ad selection, delivery, reporting
User feedback
Custom consent

Bear in mind, the IAB purposes may change, so you might need to adjust the default or custom mapping in the future.

Creating the custom IAB purposes mapping

To create a custom mapping for IAB purposes, you’ll need to create a variable in Piwik PRO Tag Manager.

To create a variable, follow these steps:

  1. Go to Menu > Tag Manager.
  2. Navigate to Variables.
  3. Click + Create new variable.
  4. Name the variable Custom IAB purposes map. If you want to use a different name, you need to make sure that it matches the one in the integration tag’s code.
  5. Pick Custom JavaScript type of a variable.
  6. In the Code editor, paste the following script:
  7.     function() {
            var INFORMATION_STORAGE_AND_ACCESS = 1;
            var PERSONALISATION = 2;
            var AD_SELECTION_DELIVERY_REPORTING = 3;
            var CONTENT_SELECTION_DELIVERY_REPOTING = 4;
            var MEASUREMENT = 5;
    
            return {
                analytics: [
                    CONTENT_SELECTION_DELIVERY_REPOTING,
                    MEASUREMENT
                ],
                ab_testing_and_personalization: [
                    INFORMATION_STORAGE_AND_ACCESS,
                    PERSONALISATION
                ],
                conversion_tracking: [],
                marketing_automation: [],
                remarketing: [
                    AD_SELECTION_DELIVERY_REPORTING
                ],
                user_feedback: []
            }
        }

    This code is the starting point, as it provides the default map. You can customize it by assigning IAB purposes to different consent types of Piwik PRO Consent Manager. You can do that by moving a purpose name to the array corresponding to a chosen consent type.

  8. When done, click Save and publish changes.
Was this article helpful?

of people found this helpful

Technical Support

If you have any questions, drop us a line at support_SPC@piwik_SPC.pro.

We’re happy to help!