Created
August 24, 2016 11:29
-
-
Save tzookb/91635c41f394c60f1d2bc9d348d42245 to your computer and use it in GitHub Desktop.
mixpanel in vue.js component
This file contains 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
let componenet = require('./componenet'); | |
Vue.app ( stuff ); | |
//this code is packaged using browserify |
This file contains 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
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'); | |
} | |
} | |
}); |
This file contains 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
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