Skip to content

Instantly share code, notes, and snippets.

@tzookb
Created August 24, 2016 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzookb/91635c41f394c60f1d2bc9d348d42245 to your computer and use it in GitHub Desktop.
Save tzookb/91635c41f394c60f1d2bc9d348d42245 to your computer and use it in GitHub Desktop.
mixpanel in vue.js component
let componenet = require('./componenet');
Vue.app ( stuff );
//this code is packaged using browserify
let Vue = require('vue');
let mixpanelMng = require('mixpanel-init');
module.exports = Vue.extend({
template: `
<div @click="mixpanelTrack()">
dont care what is here
</div>
`,
created: function() {
//this code runs as soon as this componenet is rendered
//this event is sent successfully
mixpanelMng.track('share box');
//this event is sent successfully
mixpanel.track('share box');
},
methods: {
mixpanelTrack: function() {
//this happens when user clicks soething
//this event is sent successfully, but dont get logged inside the Mixpanel admin
//so I get no error, but I can not see this in the admin
mixpanelMng.track('share box close');
//but, when I use the global mixpanel variable
//it seems to be the same, but now it is recorded in to the mixpanel admin
mixpanel.track('share box close');
}
}
});
let serverConfig = require('./server-config');
mixpanel.init(serverConfig.mixpanelToken);
module.exports = mixpanel;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment