-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathga-shim.min.js
1 lines (1 loc) · 1.44 KB
/
ga-shim.min.js
1
!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define([],b):a.GAShim=b()}(this,function(){var a={};return a._gaCommandShimMap={_addTrans:{apiName:"ecommerce:addTransaction",args:["id","affiliation","revenue","tax","shipping"]},_addItem:{apiName:"ecommerce:addItem",args:["id","sku","name","category","price","quantity"]},_trackTrans:{apiName:"ecommerce:send"},_trackEvent:{send:!0,apiName:"event",args:["eventCategory","eventAction","eventLabel","eventValue","nonInteraction"]},_trackPageview:{send:!0,apiName:"pageview",args:["page"]},_setCustomVar:function(a,b){var c=b+"set",d="dimension"+a[0],e=a[2];return[c,d,e]}},a._isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},a._isFunction=function(a){return"[object Function]"===Object.prototype.toString.call(a)},a.convertGACommandToNewGUAFormat=function(b,c){c=c?c+".":"";var d=b[0],e=b.slice(1),f=a._gaCommandShimMap[d];if(f){if(f.args){for(var g={},h=0,i=e.length;i>h;h++){var j=f.args[h];if(j){var k=e[h];k&&(g[j]=k)}}return f.send?(g.hitType=f.apiName,[c+"send",g]):[c+f.apiName,g]}return a._isFunction(f)?f.call(null,e,c):[c+f.apiName]}},a.bindShim=function(b,c,d){if(b.length>0)for(var e=0,f=b.length;f>e;e++){var g=a.convertGACommandToNewGUAFormat(b[e],d);c.apply(window,g)}b.push=function(){for(var b=0,e=arguments.length;e>b;b++){var f=arguments[b];try{var g=a.convertGACommandToNewGUAFormat(f,d);c.apply(window,g)}catch(h){throw h}}}},a});