Skip to content

Instantly share code, notes, and snippets.

@cesarandreu
Created December 5, 2014 19:48
Show Gist options
  • Select an option

  • Save cesarandreu/c1e91266c1bfc3ddd233 to your computer and use it in GitHub Desktop.

Select an option

Save cesarandreu/c1e91266c1bfc3ddd233 to your computer and use it in GitHub Desktop.
(function(n,c){
if (c[n] === void 0) {
c[n] = function () {
c[n].clients.push(this);
this._init = [Array.prototype.slice.call(arguments)];
};
c[n].clients = [];
var action = function(method){
return function () {
this['_'+method] = this['_'+method] || [];
this['_'+method].push(Array.prototype.slice.call(arguments));
return this;
};
};
var methods = ['addRecord', 'set', 'trackEvent', 'trackPageview', 'ready'];
for (var i = 0; i < methods.length; i++){
var method = methods[i];
c[n].prototype[method] = action(method);
}
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = !0;
s.src = ('https:' === document.location.protocol ? 'https:' : 'http:') + '//s3.amazonaws.com/td-cdn/sdk/td-1.2.0.js';
var t = document.getElementsByTagName('script')[0];
t.parentNode.insertBefore(s,t);
}
})('Treasure', window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment