Created
April 19, 2016 02:32
-
-
Save itochu0523/b14284bddc6b9ae3121253d81dca867a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Intimate Merger | |
!function(a,b,c,d){if(!b[a]){b[a]=function(){b[a].instances.push(this),this.init&&this.init()},b[a].instances=[];for(var e=0,f=["td_send","td_send_imid"];e<f.length;e++)b[a].prototype[f[e]]=function(a){return function(){this["tmp_"+a]=this["tmp_"+a]||[],this["tmp_"+a].push(Array.prototype.slice.call(arguments))}}(f[e]);var g=c.getElementsByTagName(d)[0],h=c.createElement(d);h.async=!0,h.src="//cf.im-apps.net/sdk/tdim-1.1.0.min.js",g.parentNode.insertBefore(h,g)}}("TDIM",window,document,"script"); | |
!function(t,e){if(void 0===e[t]){e[t]=function(){e[t].clients.push(this),this._init=[Array.prototype.slice.call(arguments)]},e[t].clients=[];for(var r=function(t){return function(){return this["_"+t]=this["_"+t]||[],this["_"+t].push(Array.prototype.slice.call(arguments)),this}},n=["addRecord","set","trackEvent","trackPageview","ready"],s=0;s<n.length;s++){var i=n[s];e[t].prototype[i]=r(i)}var a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=("https:"===document.location.protocol?"https:":"http:")+"//cdn.treasuredata.com/sdk/td-1.5.1.js";var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(a,c)}}("Treasure",this); | |
if(typeof s === "object"){ | |
var _tdObj = {}; | |
var eventsSets = [ | |
//[variable, name] | |
[s.prop1, "c1"], [s.prop2, "c2"], [s.prop3, "c3"], [s.prop4, "c4"], [s.prop5, "c5"], [s.prop6, "c6"], [s.prop7, "c7"], [s.prop8, "c8"], [s.prop9, "c9"], [s.prop10, "c10"], [s.prop11, "c11"], [s.prop12, "c12"], [s.prop12, "c13"], [s.prop14, "c14"], [s.prop15, "c15"], [s.prop16, "c16"], [s.prop17, "c17"], [s.prop18, "c18"], [s.prop19, "c19"], [s.prop20, "c20"], [s.prop21, "c21"], [s.prop22, "c22"], [s.prop23, "c23"], [s.prop24, "c24"], [s.prop25, "c25"], [s.prop26, "c26"], [s.prop27, "c27"], [s.prop28, "c28"], [s.prop29, "c29"], [s.prop30, "c30"], [s.prop31, "c31"], [s.prop32, "c32"], [s.prop33, "c33"], [s.prop34, "c34"], [s.prop35, "c35"], [s.prop36, "c36"], [s.prop37, "c37"], [s.prop38, "c38"], [s.prop39, "c39"], [s.prop40, "c40"], [s.prop41, "c41"], [s.prop42, "c42"], [s.prop43, "c43"], [s.prop44, "c44"], [s.prop45, "c45"], [s.prop46, "c46"], [s.prop47, "c47"], [s.prop48, "c48"], [s.prop49, "c49"], [s.prop50, "c50"], [s.prop51, "c51"], [s.prop52, "c52"], [s.prop53, "c53"], [s.prop54, "c54"], [s.prop55, "c55"], [s.prop56, "c56"], [s.prop57, "c57"], [s.prop58, "c58"], [s.prop59, "c59"], [s.prop60, "c60"], [s.prop61, "c61"], [s.prop62, "c62"], [s.prop63, "c63"], [s.prop64, "c64"], [s.prop65, "c65"], [s.prop66, "c66"], [s.prop67, "c67"], [s.prop68, "c68"], [s.prop69, "c69"], [s.prop70, "c70"], [s.prop71, "c71"], [s.prop72, "c72"], [s.prop73, "c73"], [s.prop74, "c74"], [s.prop75, "c75"], [s.hier1, "h1"], [s.hier2, "h2"], [s.hier3, "h3"], [s.hier4, "h4"], [s.hier5, "h5"], [s.eVar1, "v1"], [s.eVar2, "v2"], [s.eVar3, "v3"], [s.eVar4, "v4"], [s.eVar5, "v5"], [s.eVar6, "v6"], [s.eVar7, "v7"], [s.eVar8, "v8"], [s.eVar9, "v9"], [s.eVar10, "v10"], [s.eVar11, "v11"], [s.eVar12, "v12"], [s.eVar13, "v13"], [s.eVar14, "v14"], [s.eVar15, "v15"], [s.eVar16, "v16"], [s.eVar17, "v17"], [s.eVar18, "v18"], [s.eVar19, "v19"], [s.eVar20, "v20"], [s.eVar21, "v21"], [s.eVar22, "v22"], [s.eVar23, "v23"], [s.eVar24, "v24"], [s.eVar25, "v25"], [s.eVar26, "v26"], [s.eVar27, "v27"], [s.eVar28, "v28"], [s.eVar29, "v29"], [s.eVar30, "v30"], [s.eVar31, "v31"], [s.eVar32, "v32"], [s.eVar33, "v33"], [s.eVar34, "v34"], [s.eVar35, "v35"], [s.eVar36, "v36"], [s.eVar37, "v37"], [s.eVar38, "v38"], [s.eVar39, "v39"], [s.eVar40, "v40"], [s.eVar41, "v41"], [s.eVar42, "v42"], [s.eVar43, "v43"], [s.eVar44, "v44"], [s.eVar45, "v45"], [s.eVar46, "v46"], [s.eVar47, "v47"], [s.eVar48, "v48"], [s.eVar49, "v49"], [s.eVar50, "v50"], [s.eVar51, "v51"], [s.eVar52, "v52"], [s.eVar53, "v53"], [s.eVar54, "v54"], [s.eVar55, "v55"], [s.eVar56, "v56"], [s.eVar57, "v57"], [s.eVar58, "v58"], [s.eVar59, "v59"], [s.eVar60, "v60"], [s.eVar61, "v61"], [s.eVar62, "v62"], [s.eVar63, "v63"], [s.eVar64, "v64"], [s.eVar65, "v65"], [s.eVar66, "v66"], [s.eVar67, "v67"], [s.eVar68, "v68"], [s.eVar69, "v69"], [s.eVar70, "v70"], [s.eVar71, "v71"], [s.eVar72, "v72"], [s.eVar73, "v73"], [s.eVar74, "v74"], [s.eVar75, "v75"], [s.events, "v76"], [s.products, "products"], [s.pageName, "pageName"], [s.channel, "channel"], [s.server, "server"], [s.pageType, "pageType"], [s.products, "products"], [s.purchaseID, "purchaseID"], [s.campaign, "campaign"], [s.List1, "List1"], [s.List2, "List2"], [s.List3, "List3"], [s.getCk("s_vi"), "sc_cookie"], [s.getCk("swhs11_p"), "media_cd_rec"],[s.getCk("sc_cvp"), "ref_records"],[s.getCk("sc_lastvisit"), "lastvisit"] ] | |
for(var i=0; i < eventsSets.length; i++){ | |
var val = eventsSets[i][0]; | |
if(typeof val !== "undefined"){ | |
val = val + ""; | |
if(val.indexOf("D=")){ | |
_tdObj[eventsSets[i][1]] = val; | |
} | |
} | |
} | |
// imid | |
var tdimjs = new TDIM(); | |
tdimjs.debug = false; | |
tdimjs.im_api_token = "8etDGnTka2MxiIkb8Mzm7Q"; | |
var imid = (function() { | |
var cookies = document.cookie.split('; '); | |
for(var i = 0, max = cookies.length; i < max; i++){ | |
var split = cookies[i].split('='); | |
if(split[0] === '_tdim') { | |
return split[1]; | |
} | |
} | |
})(); | |
/*im cookie id */ | |
_tdObj["im_id"] = imid; | |
var td = new Treasure({ | |
host: 'in.treasuredata.com', | |
writeKey: 'YOUR_WRITE_ONLY_APIKEY_IS_HERE', | |
database: 'DATABASE_NAME' | |
}); | |
td.set('pageviews', _tdObj); | |
td.trackPageview('pageviews'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍