Forked from jbwyme/mixpanel-2.2-amd-syncronous.html
Created
December 4, 2013 11:04
-
-
Save cheeyeo/7785844 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Mixpanel AMD Example - Sync</title> | |
<script type="text/javascript" src="http://requirejs.org/docs/release/2.1.8/minified/require.js"></script> | |
<script type="text/javascript"> | |
requirejs.config({ | |
paths : { 'mixpanel': "//cdn.mxpnl.com/libs/mixpanel-2.2.min" }, | |
shim: { | |
'mixpanel': { | |
deps: ['mixpanel-preinit'], | |
exports: 'mixpanel' | |
} | |
} | |
}); | |
define("mixpanel-preinit", function(require) { | |
// this is a stripped down version of the mixpanel snippet that removes the loading of the lib via external script tag and the stubs for queuing calls | |
var b=window.mixpanel=window.mixpanel||[];var i,g;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)))}}"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";b._i.push([a,e,d])};b.__SV=1.2; | |
b.init("YOUR TOKEN"); | |
}); | |
</script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
require(['mixpanel'], function(mixpanel) { | |
mixpanel.track("my event", {prop1: "val1"}); | |
console.log(mixpanel.get_distinct_id()); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment