Follow

DFW-Tracker Installation In Google Tag Manager

Please follow the instructions below only if you use Google Tag Manager for the Google Analytics tag.

  1. Go to Container > Variables and create a new variable: 

    • Name = dfwTrackerVar
    • Type = Custom JavaScript
    • Custom Javascript:
    function() {
    function e() {
    function e() {
    return Math.floor(65536 * (1 + Math.random())).toString(16).substring(1)
    }
    return "dfwt" + e() + e() + e() + e() + e() + e()
    }

    function r(e, r) {
    function n(e) {
    0 === e.indexOf('"') && (e = e.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, "\\"));
    try {
    return e.replace(/\+/g, " ")
    } catch (r) {}
    return ""
    }
    if (i(r)) {
    var o = new Date;
    return o.setTime(o.getTime() + 63072e6), t.cookie = e + "=" + r + ("; expires=" + o.toUTCString()) + "; path=/"
    }
    for (var c, f, d, a = e ? void 0 : {}, u = t.cookie ? t.cookie.split("; ") : [], l = 0, k = u.length; k > l; l++) {
    if (c = u[l].split("="), f = c.shift(), d = c.join("="), e && e === f) {
    a = n(d);
    break
    }!e && i(d = n(d)) && (a[f] = d)
    }
    return a
    }

    function i(e) {
    return null === e ? !1 : void 0 !== e
    }
    var t = document,
    n = "_dfwt",
    o = /dfw_tracker=([0-9a-zA-Z\-\_]+)/.exec(location.href);
    if (null !== o && i(o[1]) && (o = o[1]), "string" == typeof o) {
    var c = r(n);
    i(c) || (c = e(), r(n, c));
    return c + "-" + o
    }
    }

    Go to Container > Triggers and set up the following trigger: Trigger with tracker

    • Name = pages with dfw_tracker
    • Event = Page View
    • Trigger type = Page View
    • Fire On = Page URL contains dfw_tracker
  2. Go to Container > Tags and open your current Universal Analytics Tag and click "Copy" in the bottom right corner. This will create a copy of your UE tag UA Tag with tracker

    For convenience, change the name of this tracker to "Universal Analytics with tracker".

    Set the following:

    • Custom Dimensions > Index = the Index of the dfw_tracker custom dimension that was created automatically in Google Analytics when you installed DFW-Analytics:Custom Dimension Index
    • Custom Dimensions > Dimension Value = {{dfwTrackerVar}}
    • Fire On = page with dfw_tracker

    Click the "Save Tag" button at the bottom, when you are finished.

  3. Open the original Universal Analytics tag again. Under “Fire On” section click “Create Exceptions”, select the “pages with dfw_tracker” trigger and click “Save”.

    Now your original UA tag should look something like this:original UA tag Click the "Save Tag" button at the bottom, when you are finished.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk