Skip to content

Instantly share code, notes, and snippets.

@kevj408
Created July 12, 2018 00:49
Show Gist options
  • Save kevj408/df1efd0aeb8c19f03c720ba098f9d54d to your computer and use it in GitHub Desktop.
Save kevj408/df1efd0aeb8c19f03c720ba098f9d54d to your computer and use it in GitHub Desktop.
//tealium universal tag - utag.318 ut4.0.201701161351, Copyright 2017 Tealium.com Inc. All Rights Reserved.
try{(function(id,loader){var u={"id":id};utag.o[loader].sender[id]=u;if(utag.ut===undefined){utag.ut={};}
var match=/ut\d.(\d*)../.exec(utag.cfg.v);if(utag.ut.loader===undefined||!match||parseInt(match[1])<41){u.loader=function(o,a,b,c,l,m){utag.DB(o);a=document;if(o.type=="iframe"){m=a.getElementById(o.id);if(m&&m.tagName=="IFRAME"){b=m;}else{b=a.createElement("iframe");}o.attrs=o.attrs||{};utag.ut.merge(o.attrs,{"height":"1","width":"1","style":"display:none"},0);}else if(o.type=="img"){utag.DB("Attach img: "+o.src);b=new Image();}else{b=a.createElement("script");b.language="javascript";b.type="text/javascript";b.async=1;b.charset="utf-8";}if(o.id){b.id=o.id;}for(l in utag.loader.GV(o.attrs)){b.setAttribute(l,o.attrs[l]);}b.setAttribute("src",o.src);if(typeof o.cb=="function"){if(b.addEventListener){b.addEventListener("load",function(){o.cb();},false);}else{b.onreadystatechange=function(){if(this.readyState=="complete"||this.readyState=="loaded"){this.onreadystatechange=null;o.cb();}};}}if(o.type!="img"&&!m){l=o.loc||"head";c=a.getElementsByTagName(l)[0];if(c){utag.DB("Attach to "+l+": "+o.src);if(l=="script"){c.parentNode.insertBefore(b,c);}else{c.appendChild(b);}}}};}else{u.loader=utag.ut.loader;}
if(utag.ut.encode===undefined){u.encode=function(a,b){b="";try{b=encodeURIComponent(a)}catch(e){utag.DB(e);}if(b==""){b=escape(a);}return b;};}else{u.encode=utag.ut.encode;}
u.ev={"view":1};u.map={"tag_id":"mt_id","customer_hashed_email":"mt_exem","analytics_pagename":"s1","product_quantity":"s2","product_gender":"s3","product_sport":"s4","order_promo_codes":"s5","product_color":"s6","product_model_id":"s7,v7","product_group":"s8","product_brand":"s9","order_id":"s10","order_subtotal":"v1","total_products":"v2","mobile_transactions":"v3","mobile_items_sold":"v4","is_customizable":"v5","product_category":"v6","product_price":"v8","product_id":"v9","geo_country":"v10"};u.extend=[function(a,b){try{if(b['is_customizable'].toString().toLowerCase()=='TRUE'.toLowerCase()){b['is_customizable']='1'}}catch(e){utag.DB(e)}},function(a,b){if(!(b.page_type=='SHOPPING CART'||b.page_type=='PDP'||b.order_id)){b.product_id=b.product_model_id=[];}
if(!b.product_gender||(Array.isArray(b.product_gender)&&b.product_gender.length==0)){b.product_gender=[b.filter_gender||''];}else{b.filter_gender=b.product_gender[0];}
if(!b.product_category||(Array.isArray(b.product_category)&&b.product_category.length==0)){b.product_category=[b.filter_category||''];}else{b.filter_category=b.product_category[0];}
if(!b.product_sport||(Array.isArray(b.product_sport)&&b.product_sport.length==0)){b.product_sport=[b.filter_sport||''];}else{b.filter_sport=b.product_sport[0];}
if(!b.product_brand||(Array.isArray(b.product_brand)&&b.product_brand.length==0)){b.product_brand=[b.filter_brand||''];}else{b.filter_brand=b.product_brand[0];}
if(Array.isArray(b.product_model_id)){b.product_model_id_first=b.product_model_id[0];}
if(!b.product_line_style||(Array.isArray(b.product_line_style)&&b.product_line_style.length==0)){b.product_line_style=[b.filter_product_line_style||''];}},function(a,b,c,d,e,f,g){d=b['page_type'];if(typeof d=='undefined')return;c=[{'HOME':'1070510'},{'CLP':'1070512'},{'PLP':'1070512'},{'PDP':'1070513'},{'CART':'1070514'}];var m=false;for(e=0;e<c.length;e++){for(f in c[e]){if(d.toString().indexOf(f)>-1){b['tag_id']=c[e][f];m=true};};if(m)break};if(!m)b['tag_id']='';},function(a,b){try{if((typeof b['page_type']!='undefined'&&b['page_type']!=''&&b['page_owner'].toString().toLowerCase()=='BRAND'.toLowerCase())){b['tag_id']='1070512'}}catch(e){utag.DB(e)}},function(a,b){try{if((b['page_name'].toString().toLowerCase()=='EMAIL SIGNUP'.toLowerCase()&&b['signup_step'].toString().toLowerCase()=='START'.toLowerCase())){b['tag_id']='1070515'}}catch(e){utag.DB(e)}},function(a,b){try{if((b['page_name'].toString().toLowerCase()=='EMAIL SIGNUP'.toLowerCase()&&b['signup_step'].toString().toLowerCase()=='SUCCESS'.toLowerCase())){b['tag_id']='1070516'}}catch(e){utag.DB(e)}},function(a,b){try{if((b['page_type'].toString().toLowerCase()=='CHECKOUT'.toLowerCase()&&b['page_name'].toString().toLowerCase()=='COMPLETE'.toLowerCase()&&typeof b['order_id']!='undefined'&&typeof b['order_id']!='undefined'&&b['order_id']!='')){b['tag_id']='1070524'}}catch(e){utag.DB(e)}},function(a,b){if(!b.tag_id){return false;}},function(a,b){utag.ut.sha1=function(e,m){var p={},j=p.lib={},l=function(){},f=j.Base={extend:function(a){l.prototype=this;var c=new l;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},n=j.WordArray=f.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=m?c:4a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var c=this.words,q=a.words,d=this.sigBytes;a=a.sigBytes;this.clamp();if(d%4)for(var b=0;b<a;b++)c[d+b>>>2]|=(q[b>>>2]>>>24-8*(b%4)&255)<<24-8*((d+b)%4);else if(65535<q.length)for(b=0;b<a;b+=4)c[d+b>>>2]=q[b>>>2];else c.push.apply(c,q);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<32-8*(c%4);a.length=e.ceil(c/4)},clone:function(){var a=f.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b<a;b+=4)c.push(4294967296e.random()|0);return new n.init(c,a)}}),b=p.enc={},h=b.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d<a;d++){var f=c[d>>>2]>>>24-8(d%4)&255;b.push((f>>>4).toString(16));b.push((f&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d<c;d+=2)b[d>>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return new n.init(b,c/2)}},g=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d<a;d++)b.push(String.fromCharCode(c[d>>>2]>>>24-8*(d%4)&255));return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d<c;d++)b[d>>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return new n.init(b,c)}},r=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},k=j.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new n.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=r.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,b=c.words,d=c.sigBytes,f=this.blockSize,h=d/(4f),h=a?e.ceil(h):e.max((h|0)-this._minBufferSize,0);a=hf;d=e.min(4a,d);if(a){for(var g=0;g<a;g+=f)this._doProcessBlock(b,g);g=b.splice(0,a);c.sigBytes-=d}return new n.init(g,d)},clone:function(){var a=f.clone.call(this);a._data=this._data.clone();return a},_minBufferSize:0});j.Hasher=k.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){k.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,b){return(new a.init(b)).finalize(c)}},_createHmacHelper:function(a){return function(b,f){return(new s.HMAC.init(a,f)).finalize(b)}}});var s=p.algo={};return p}(Math);(function(){var e=utag.ut.sha1,m=e.lib,p=m.WordArray,j=m.Hasher,l=[],m=e.algo.SHA1=j.extend({_doReset:function(){this._hash=new p.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(f,n){for(var b=this._hash.words,h=b[0],g=b[1],e=b[2],k=b[3],j=b[4],a=0;80>a;a++){if(16>a)l[a]=f[n+a]|0;else{var c=l[a-3]^l[a-8]^l[a-14]^l[a-16];l[a]=c<<1|c>>>31}c=(h<<5|h>>>27)+j+l[a];c=20>a?c+((g&e|~g&k)+1518500249):40>a?c+((g^e^k)+1859775393):60>a?c+((g&e|g&k|e&k)-1894007588):c+((g^e^k)-899497514);j=k;k=e;e=g<<30|g>>>2;g=h;h=c}b[0]=b[0]+h|0;b[1]=b[1]+g|0;b[2]=b[2]+e|0;b[3]=b[3]+k|0;b[4]=b[4]+j|0},_doFinalize:function(){var f=this._data,e=f.words,b=8this._nDataBytes,h=8f.sigBytes;e[h>>>5]|=128<<24-h%32;e[(h+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(h+64>>>9<<4)+15]=b;f.sigBytes=4e.length;this._process();return this._hash},clone:function(){var e=j.clone.call(this);e._hash=this._hash.clone();return e}});e.SHA1=j._createHelper(m);e.HmacSHA1=j._createHmacHelper(m)})();try{if(typeof b['customer_hashed_email']!='undefined'&&b['customer_hashed_email']!=''){b['customer_hashed_email']=utag.ut.sha1.SHA1(b['customer_hashed_email']).toString();}}catch(e){}}];u.send=function(a,b){if(u.ev[a]||u.ev.all!==undefined){utag.DB("send:318");utag.DB(b);var c,d,e,f;u.data={"qsp_delim":"&","base_url":"//pixel.mathtag.com/event/","mt_adid":"172909","mt_id":"","type":"js"};for(c=0;c<u.extend.length;c++){try{d=u.extendc;if(d==false)return}catch(e){if(typeof utag_err!='undefined'){utag_err.push({e:'extension error:'+e,s:utag.cfg.path+'utag.'+id+'.js',l:c,t:'ex'})}}};utag.DB("send:318:EXTENSIONS");utag.DB(b);c=[];for(d in utag.loader.GV(u.map)){if(b[d]!==undefined&&b[d]!==""){e=u.map[d].split(",");for(f=0;f<e.length;f++){u.data[e[f]]=u.encode(Array.isArray(b[d])?b[d].join(":"):b[d]);}}}
utag.DB("send:318:MAPPINGS");utag.DB(u.data);c.push("mt_id="+u.data.mt_id);c.push("mt_adid="+u.data.mt_adid);if(u.data.mt_exem){c.push("mt_exem="+u.data.mt_exem);}else if(u.data.mt_excl){c.push("mt_excl="+u.data.mt_excl);}
for(var i=1;i<=10;i++){if(u.data["v"+i]){c.push("v"+i+"="+u.data["v"+i]);}
if(u.data["s"+i]){c.push("s"+i+"="+u.data["s"+i]);}}
if(!u.data.mt_id){utag.DB(u.id+": Tag not fired: Required attribute not populated [mt_id]");return;}
if(!u.data.mt_adid){utag.DB(u.id+": Tag not fired: Required attribute not populated [mt_adid]");return;}
u.data.base_url=u.data.base_url+u.data.type+"?"+c.join(u.data.qsp_delim)+"&skipsync=20";u.loader({"type":u.data.type,"src":u.data.base_url,"loc":"script","id":"utag_318"});utag.DB("send:318:COMPLETE");}};utag.o[loader].loader.LOAD(id);}("318","adidas.adidasglobal"));}catch(error){utag.DB(error);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment