Skip to content

Instantly share code, notes, and snippets.

@mohitmayank
Last active December 20, 2015 16:38
Show Gist options
  • Save mohitmayank/6162576 to your computer and use it in GitHub Desktop.
Save mohitmayank/6162576 to your computer and use it in GitHub Desktop.
AMD Mixpanel 2.2 Javascript Load Snippet
/*global require*/
'use strict';
require.config({
paths: {
'mixpanel' : '//cdn.mxpnl.com/libs/mixpanel-2.2.min',
},
shim: {
mixpanel: {
exports : 'mixpanel',
},
},
});
require([
'mixpanel-snippet',
], function (mixpanel) {
mixpanel.track("Landing Page AMD SHIM TRIM");
});
define(function(){
var b = window.mixpanel || [];
if (!b.__SV) {
var i, g;
window.mixpanel = b;
b._i = [];
b.init = function (a, e, d) {
function f(b, h) {
var a = h.split(".");
2 == a.length && (b = b[a[0]], h = a[1]);
b[h] = function () {
b.push([h].concat(Array.prototype.slice.call(arguments, 0)))
}
}
var c = b;
"undefined" !==
typeof d ? c = b[d] = [] : d = "mixpanel";
c.people = c.people || [];
c.toString = function (b) {
var a = "mixpanel";
"mixpanel" !== d && (a += "." + d);
b || (a += " (stub)");
return a
};
c.people.toString = function () {
return c.toString(1) + ".people (stub)"
};
i = "disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");
for (g = 0; g < i.length; g++)
f(c, i[g]);
b._i.push([a, e, d])
};
b.__SV = 1.2
}
b.init("YOUR TOKEN");
require(['mixpanel'], function(mixpanel){});
return b;
});
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Test Landing Page</title>
<script src="./public/vendor/require/require.js" data-main="./public/scripts/mixpanel-amd-main.js"></script>
</head>
<body>
This is a test page.
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment