convertionanalytics-tracking
Version:
Track events - custom user actions, clicks, pageviews, purchases.
27 lines (21 loc) • 1.2 kB
JavaScript
!function(name,path,ctx){
var latest,prev=name!=="Keen"&&window.Keen?window.Keen:false;ctx[name]=ctx[name]||{ready:function(fn){var h=document.getElementsByTagName("head")[0],s=document.createElement("script"),w=window,loaded;s.onload=s.onreadystatechange=function(){if((s.readyState&&!(/^c|loade/.test(s.readyState)))||loaded){return}s.onload=s.onreadystatechange=null;loaded=1;latest=w.Keen;if(prev){w.Keen=prev}else{try{delete w.Keen}catch(e){w.Keen=void 0}}ctx[name]=latest;ctx[name].ready(fn)};s.async=1;s.src=path;h.parentNode.insertBefore(s,h)}}
}("Keen","./keen-tracking.js",this);
/*!
----------------------------------------------------------------------
Example Usage:
1) Namespace: Define a custom namespace for the library
2) Script URI: Define the location of the script to load
3) Context: Define where the library should be installed
----------------------------------------------------------------------
var modules = {};
!function(name, path, ctx) {
// ... etc
}('MyKeen', './my-keen-build.js', modules);
modules.MyKeen.ready(function(){
var client = new modules.MyKeen.Client({
projectId: '123',
writeKey: '4324543'
});
});
*/