Script Loader Function u.loader

View Snippet
                    var tealium_script_loader = function(o) {
    var a, b, c, l;
    a = document;
    if (o.type === "iframe") {
        b = a.createElement("iframe");
        b.setAttribute("height", "1");
        b.setAttribute("width", "1");
        b.setAttribute("style", "display:none");
        b.setAttribute("src", o.src);
    } else if (o.type === "img") {        
        b = new Image();
        b.src = o.src;
        return;
    } else {
        b = a.createElement("script");
        b.language = "javascript";
        b.type = "text/javascript";
        b.async = 1;
        b.charset = "utf-8";
        b.src = o.src;
    }
    if (o.id) {
        b.id = o.id;
    }   
    l = o.loc || "head";
    c = a.getElementsByTagName(l)[0];
    if (c) {       
        if (l === "script") {
            c.parentNode.insertBefore(b, c);
        } else {
            c.appendChild(b);
        }
    }
};
                  

Tealium : Single Page App Handling

View Snippet
                    /*
################################
### SINGLE PAGE APP HANDLING ###
################################

Author : roshan@tealium.com

Notes
=====

- This extension will handle single page apps if declared in the universal data object (UDO)

- Must be scoped to PRE-LOADER

*/

// JS Code in Preloader Extension
window.utag_data = window.utag_data || {};
window.utag_cfg_ovrd = window.utag_cfg_ovrd || {};

if(utag_data.site_type === "single page"){window.utag_cfg_ovrd.noview = true;} // stops first page load happening
                  

New Collect tag workaround : scope to tag

View Snippet
                    // SCOPE TO TAG TO ENSURE COMPATIBLE ON OLDER UTAG VERSIONS
// author : roshan@tealium.com

if (!utag.ut.pad) {
  utag.ut.pad = function(a, b, c, d) {
    a = "" + ((a - 0).toString(16));
    d = '';
    if (b > a.length) {
      for (c = 0; c < (b - a.length); c++) {
        d += '0'
      }
    }
    return "" + d + a
  }
}
if (!utag.ut.vi){utag.ut.vi = function(t, a, b) {
    if (!utag.v_id) {
      a = this.pad(t, 12);
      b = "" + Math.random();
      a += this.pad(b.substring(2, b.length), 16);
      try {
        a += this.pad((navigator.plugins.length ? navigator.plugins.length : 0), 2);
        a += this.pad(navigator.userAgent.length, 3);
        a += this.pad(document.URL.length, 4);
        a += this.pad(navigator.appVersion.length, 3);
        a += this.pad(screen.width + screen.height + parseInt((screen.colorDepth) ? screen.colorDepth : screen.pixelDepth), 5)
      } catch (e) {
        utag.DB(e);
        a += "12345"
      };
      utag.v_id = a;
    }
    return utag.v_id
  }
}


if(!utag.ut.hasOwn){utag.ut.hasOwn = function(o, a) {
    return o != null && Object.prototype.hasOwnProperty.call(o, a)
  }
}

if(!utag.ut.isEmptyObject){utag.ut.isEmptyObject = function(o, a) {
    for (a in o) {
      if (utag.ut.hasOwn(o, a)) return false
    }
    return true
  }
}

if(!utag.ut.isEmpty){utag.ut.isEmpty = function(o) {
    var t = utag.ut.typeOf(o);
    if (t == "number") {
      return isNaN(o)
    } else if (t == "boolean") {
      return false
    } else if (t == "string") {
      return o.length === 0
    } else return utag.ut.isEmptyObject(o)
  }
}

  if(!utag.ut.typeOf){utag.ut.typeOf = function(e) {
    return ({}).toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
  }
}

if(!utag.ut.flatten){utag.ut.flatten = function(o) {
    // stop when arriving at a string, array, boolean, number (float or integer)
    var a = {};

    function r(c, p) {
      if (Object(c) !== c || c instanceof Array) {
        a[p] = c;
      } else {
        if (utag.ut.isEmptyObject(c)) {
          //a[p] = {};
        } else {
          for (var d in c) {
            r(c[d], p ? p + "." + d : d);
          }
        }
      }
    }
    r(o, "");

    return a;
  }
}

if(!utag.merge){utag.ut.merge = function(a, b, c, d) {
    if (c) {
      for (d in utag.loader.GV(b)) {
        a[d] = b[d]
      }
    } else {
      for (d in utag.loader.GV(b)) {
        if (typeof a[d] == "undefined") a[d] = b[d]
      }
    }
  }
}
if(!utag.ut.decode){utag.ut.decode = function(a, b) {
    b = "";
    try {
      b = decodeURIComponent(a)
    } catch (e) {
      utag.DB(e)
    };
    if (b == "") {
      b = unescape(a)
    };
    return b
  }
}

                  

Remove line breaks/white space

View Snippet
                    exampleString.replace(/\r\n|\s{2,}/gm,"");
                  

AXEL : DIP data stripper

View Snippet
                    /*
###########################################
### TEALIUM COLLECT : DIP DATA STRIPPER ###
###########################################

Author : roshan@tealium.com

Notes:
This extension:

- Should ALWAYS be scoped to the DIP Tealium Collect Pixel
- Will remove any data sources without the relevant reserved prefix (e.g. "dip_")
- You can configure the reserved prefixes below
- There are DIP specific prefixes declared in the 'dip_prefixes' array
- There are Tealium specific prefixes required for Tealium Collect to function correctly in the 'tealium_functional_prefixes' array

*/

// Configuration

var dip_prefixes = ["cp.dip", "dip_"]; // these are DIP specific data sources

var tealium_functional_prefixes = ["cp.trace","cp.utag", "_t_","dom.","ut."]; // these are required for Tealium to function correctly

// ### DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ###

var reserved_prefixes = dip_prefixes.concat(tealium_functional_prefixes);

for (varName in b) {

	var keep_var = false;

	for (var i = 0; i < reserved_prefixes.length; i++) {
	
		if (varName.indexOf(reserved_prefixes[i]) === 0) {

			var keep_var = true;

		}
	};

	if (keep_var === false){

		if(utag.ut.typeOf(b[varName]) === "array"){
			b[varName] === b[varName].slice(0);
		}

		delete b[varName];

	}

}