Mixpanel 2.2 within an AMD structured web-app - e.g. require.js

后端 未结 4 642
[愿得一人]
[愿得一人] 2021-02-06 09:55

I\'m attempting to make use of Mixpanel event tracking in a single page site based on Backbone.js and require.js.

Looking at the snippet that Mixpanel provide for cut-an

4条回答
  •  悲哀的现实
    2021-02-06 10:18

    As of mixpanel's 2.7.x release, they now support multiple AMD/UMD versions compatible with requirejs, you can grab it on their github page: https://github.com/mixpanel/mixpanel-js

    requirejs(['./mixpanel.amd'], function(mixpanel) {
    
        mixpanel.init("FAKE_TOKEN", {
            debug: true,
            loaded: function() {
                mixpanel.track('loaded() callback works but is unnecessary');
                alert("Mixpanel loaded successfully via RequireJS/AMD");
            }
        });
    
        mixpanel.track('Tracking after mixpanel.init');
    
    });
    

提交回复
热议问题