Skip to content

Instantly share code, notes, and snippets.

@yields
Last active December 31, 2015 12:09
Show Gist options
  • Save yields/7984563 to your computer and use it in GitHub Desktop.
Save yields/7984563 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
window.analytics || (window.analytics = []), window.analytics.methods = ["identify", "track", "trackLink", "trackForm", "trackClick", "trackSubmit", "page", "pageview", "ab", "alias", "ready", "group", "on", "once", "off"], window.analytics.factory = function (t) {
return function () {
var a = Array.prototype.slice.call(arguments);
return a.unshift(t), window.analytics.push(a), window.analytics
}
};
for (var i = 0; i < window.analytics.methods.length; i++) {
var method = window.analytics.methods[i];
window.analytics[method] = window.analytics.factory(method)
}
window.analytics.load = function (t) {
var a = document.createElement("script");
a.type = "text/javascript", a.async = 0, a.src = 'ajs.js';
var n = document.getElementsByTagName("script")[0];
n.parentNode.insertBefore(a, n)
}, window.analytics.SNIPPET_VERSION = "2.0.8",
window.analytics.load("baz");
window.analytics.page();
</script>
<script>
(function(){
var ajs = window.analytics;
setTimeout(function(){
window.analytics.identify('baz'); // => ok!
ajs.identify('baz'); // => "Uncaught TypeError: Object #<Analytics> has no method 'push'"
}, 300);
})();
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment