Please bear with me, I'm not a developer.
I'd like to track the event of a site visitor clicking on my Twitter Follow Button with Mixpanel
. Hence I run the following Mixpanel
event/name:
<script> function clickTwitterFollowB() {
mixpanel.track("Twitter button");
}</script>
I use onclick
to load the Mixpanel
function when the Twitter button is clicked:
onclick="clickTwitterFollowB()"
And this is the Twitter Button code where I insert the above:
<a href="https://twitter.com/myAccount" onclick="clickTwitterFollowB()" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @myAccount</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
When I do the above, the event is not tracked, but it does track it does work on links "a""/a" and "button""/button".
Any ideas/suggestions on what might be wrong with this event tracking code?
Clinking the link loads another page, at which point the JS on your page is no longer relevant.
You have a couple options: How do I log a MixPanel event when a user clicks a link?