DG and Privacy UX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Consent Solutions Knowledge Base

Implementing IAB Support in the Evidon UCP

Enabling IAB

 
The UCP support for the IAB consent platform is not enabled by default.  In order for IAB support to be active on a given location (domain/country combination) you need to do the following:
 
1.  Log into the Evidon Privacy Application
2.  Modify/Create a new Domain listing
3.  Select the countries/regions where you want to support the IAB consent platform.
4.  Enable the Privacy Options Dialog (if not already enabled)
5.  Select the "Enable IAB Support" option
 
iab
 
Walk through the rest of the settings pages and save your changes.
 
At this point IAB support has been enabled for that domain and selected country(ies).
 
 

Deploying IAB Support

 
To support the IAB consent framework will require a script change which needs to be deployed to the web properties.  The IAB protocol specifies a common API be available on the supporting web properties, providing a common communcation interface between the advertisers and the cmp.
 
Without going into a ton of technical details this interface is called "__cmp".  The crucial thing is this object interface needs to be available BEFORE ANY ADVERTISER TAGS EXECUTE.  When the tags execute they may request which purposes are enabled, which they will do by making a call to the __cmp interface.  If that doesn't exist that call will fail.
 
To make sure the "__cmp" interface is available we provide a default impleemntation of that interface that needs to be deployed onto your page as soon as possible, ideally the first script added to your page.  To make sure that happens we recommend you do not deploy this script through a tag manager or as a separate script, but add it to the root site template.  If you deploy it to a location where IAB support is not desired it will not hurt anything and the overhead is minimal.
 
 
 

__cmp Stub Script

 
Here is the stub script, with additional comments, so you can review it and what it does. This is the exact script we provide so you can add it to your site if you want.  You may want to minify it first to conserve space though.
 
<script>
(function () {
    var gdprAppliesGlobally = false;
 
    // based on the IAB spec this frame is required so advertisers running in child frames can
    // look for IAB support.  The frame itself doesn't do anything, it just acts as a marker.
    function addFrame() {
        if (!window.frames['__cmpLocator']) {
            if (document.body) {
                var body = document.body,
                    iframe = document.createElement('iframe');
                iframe.style.cssText = 'display:none';
                iframe.name = '__cmpLocator';
                body.appendChild(iframe);
            } else {
                // In the case where this stub is located in the head,
                // this allows us to inject the iframe more quickly than
                // relying on DOMContentLoaded or other events.
                setTimeout(addFrame, 5);
            }
        }
    }
 
    // init the add frame call
    addFrame();
 
    // this creates the stub implementation of the __cmp object.  With this
    // implementation the calls from advertisers are stored in an array which
    // is processed by the evidon-cmp script when it loads.
    function stubCMP() {
        var args = arguments;
        // console.log('stubCMP', args);
        __cmp.a = __cmp.a || [];
 
        if (!args.length) return __cmp.a;
        else if (args[0] === 'ping') {
            args[2]({
                "gdprAppliesGlobally": gdprAppliesGlobally,
                "cmpLoaded": false
            }, true);
        }
        else {
            __cmp.a.push([].slice.apply(args));
        }
    }
 
    // this creates the message handler that handles calls from child frames where
    // they are not able to access the __cmp api directly.
    function cmpMsgHandler(event) {
        var msgIsString = typeof event.data === "string";
        var json = msgIsString ? JSON.parse(event.data) : event.data;
        if (!json.__cmpCall) return;
 
        var call = json.__cmpCall;
        window.__cmp(call.command, call.parameter, function (retValue, success) {
            var returnMsg = {
                "__cmpReturn": {
                    "returnValue": retValue,
                    "success": success,
                    "callId": call.callId
                }
            };
 
            event.source.postMessage(msgIsString ?
                JSON.stringify(returnMsg) : returnMsg, '*');
        });
    }
 
    // this looks to see if the __cmp is present or not on the page.   If not
    // we add the stub.
    if (typeof (__cmp) !== 'function') {
        window.__cmp = stubCMP;
        __cmp.msgHandler = cmpMsgHandler;
 
        if (window.addEventListener)
            window.addEventListener('message', cmpMsgHandler, false);
        else
            window.attachEvent('onmessage', cmpMsgHandler);
    }
})();
</script>

Labels (1)
Version history
Revision #:
2 of 2
Last update:
‎05-15-2019 07:33 PM
Updated by:
 
Contributors
Looking for more?
Ask in Discussions
Developers

Peer-to-peer support  and answers on developing CMS templates, modifying privacy scripts or building integrations.

Digital Experience Management

Find answers and ask questions on content management, personalization and targeting.

Digital Quality Management

Find answers and ask questions on WCAG and SEO quality management.

Digital Governance

Find answers and ask questions on consent and monitoring solutions.