Question

Mixpanel tracking code does not work

  • 9 August 2019
  • 5 replies
  • 1382 views

Badge

I followed this tutorial
https://developer.mixpanel.com/docs/javascript
But I didn’t get any data.

You can see I added Mixpanel in my header. The source code is at here
https://github.com/Hongbo-Miao/hongbomiao.com/blob/master/public/index.html#L12-L17



5 replies

Userlevel 1
Badge

@Hongbo-Miao

There could be a couple of things that can cause no data to be sent to your project. I had some trouble when I first started implementing Mixpanel (definitely a learning curve). This article was really helpful for me to troubleshot my implementation when I was not getting data in it https://community.mixpanel.com/questions/2560/no-data-in-project-articles-from-the-archive.html

Hope this helps!


Badge

Thanks, Frank.

However, when I tried

mixpanel.init("my_token", {debug:true});

it returned undefined.

Also, the Mixpanel Debugger didn't detect anything.


Userlevel 1
Badge

hmmm....I went on your Github and cannot find where you are implementing your mixpanel.track() calls. Can you share what file you are doing this on? I might be able to take a closer look from there 🙂


Badge

Hi Frank, sorry, I removed since I cannot make it work. But the history PR shows it. The code is just like this https://github.com/Hongbo-Miao/hongbomiao.com/pull/59/files


Userlevel 1
Badge

@Hongbo-Miao Thanks! I took a look and it looks like you added the Javascript library to your <head> tag in the index.html file. The second step would be to add mixpanel.track() call on your project to send events.

To very quickly capture your first event, you can add this call at the end of your index.html file - right before your closing </body> tag

<script> mixpanel.track("THE NAME OF YOUR EVENT HERE");</script>

This should capture your first event along with the default properties that come with client-side libraries.

I see that you have some javascript files(jsx) where you could do more concentrated event capturing (like create functionality to capture event properties and even people profiles). I think it would be helpful to see their Implementation course to get more information on setting up more tracking in your website. Hopefully this helps get your website tracking running!


Reply


Mixpanel