Skip to content

Instantly share code, notes, and snippets.

@araddon
Last active January 3, 2016 14:39
Show Gist options
  • Save araddon/8478107 to your computer and use it in GitHub Desktop.
Save araddon/8478107 to your computer and use it in GitHub Desktop.
page level data for all events
window.jstag=function(){var t={_q:[],_c:{},ts:(new Date).getTime()},l=false,w=window,d=document,src="/static/io",as=Array.prototype.slice,sp;t.init=function(c){sp=c.js?c.js:c.url||"";c.ext=c.ext||".min.js";t._c=c;return this};t.load=function(){var js,fjs=d.getElementsByTagName("script")[0];l=true;if(d.getElementById(src))return this;js=d.createElement("script");js.id=src;js.src=sp+src+t._c.ext;fjs.parentNode.insertBefore(js,fjs);return this};t.bind=function(e){this._q.push([e,as.call(arguments,1)])};t.ready=function(){this._q.push(["ready",as.call(arguments)])};t.send=function(){if(!l)this.load();this._q.push(["ready","send",as.call(arguments)]);return this};return t}();
jstag.init({cid:"CUSTOMER_ID",url:'//c.lytics.io',ext:".js"})
jstag.bind("send.before",function(o,io){
// will be sent on all events on this page
o.data["mystuff"] = 'here';
o.data["arrayofstuff"] = ["category1","category2"];
})
// only sent once on page load
jstag.send({"category":"hello","catid":6});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment