Tutorial

GDPR

Overview

GDPR implementation in XTagManager consists in:

  • Switching AT Internet in Privacy mode.
  • Blocking Google Analytics.
  • Possibly blocking Google Tag Manager container, if any.

It is achieved by implementing the Global Customizer isCustomOptedIn

Then, it can be saved in a dedicated file stored in the Debug Path and included in all your Customization JS.

For example, once stored in std_optedin.js:

/*#include std_optedin.js*/

From a simple cookie

In example below, GDPR mode is switched from a cookie value, with Google Tag Manager blocking:

/**
 * @license @title GDPR Privacy from cookie
 * @author DENIS ROUSSEAU
 * @version 8.6.0.0
 */
/*jslint nomen: true, plusplus: true, regexp: true*/
/**
 * Cookie Privacy 
 */
function isCustomOptedIn()
{
    /* Expect an explicit consent (default optout) */
    var ok=(stat_data.getCookie('privacy')==='yes');
    stat_extent.gtm.active=ok;
    return ok;
}

From Commander Act Trust opt-outs

To take into account Tag Commander privacy module, you can use the following snippet:

/**
 * @license @title Commander Act / Tag Commander Trust
 * @author DENIS ROUSSEAU
 * @version 8.6.3.0
 */
/*jslint nomen: true, plusplus: true, regexp: true*/
/**
 * Tag Commander Privacy 
 */
function isCustomOptedIn()
{
    /* By default, statistics cookies are allowed, marketing cookies are not */
    var ok=true, mk=false, c=stat_extent.tc.getPrivacy(), 
    /* Rely on internal API if tC.privacy still not available */
    ac=(window.tC && tC.privacy && typeof tC.privacy.getOptinCategories==='function')?tC.privacy.getOptinCategories():stat_extent.tc.getOptinCategories(), 
    i=0, vi=0,vm=1000, p=getPageParam('statp');
    /* Test Mode: no TC opt-out */
    if (p==='2')
    {
        stat_extent.tc.resetPrivacy();                   
    }    
    /* Legacy Privacy implementation */
    else if (ac.length===0)
    {
        if (c)
        {     
            ac=decodeURIComponent(c).split(',');
            /* Find the smaller one */
            for (i=0;i<ac.length;i++)
            {
                if (!isNaN(ac[i]))
                {
                    vi=parseInt(ac[i],10);
                    if (vi<vm)
                    {
                        vm=vi;
                    }
                }
            }
            /* Convert as Trust Center implementation */
            c="";
            for (i=0;i<ac.length;i++)
            {
                if (!isNaN(ac[i]))
                {
                    c+=((c?',':'')+(parseInt(ac[i],10)-vm+1).toString(10));
                }
            }
            ac=c.split(',');
        }
    }    
    /* Trust Center implementation */
    if (ac.length>0)
    {
        /* Array contains only one empty element or ALL: true by default (=>default optin, invert it for default optout) */
        ok=(ac.length===1 && (!ac[0]||ac[0]==='ALL'));
        for (i=0;i<ac.length;i++)
        {
            switch (ac[i])            
            {
            case '2': ok=true;break;
            case '4': mk=true;break;
            }
        } 
    }
    /*
     * Block GTM container, if any
     */
    if (!ok || !mk)
    {
        stat_extent.gtm.active=false;
    }    
    return ok;    
}