Search code examples
phpjavascriptanalyticsmixpanel

mixpanel analytic in wordpress blog not working


I am trying to use mixpanel for analytic in my Wordpress blog (just for learning).

My blog is all php.

I got the code from mixpanel's website and put it in my header.php file.

<!-- start Mixpanel --><script type="text/javascript">(function(c,a){window.mixpanel=a;var b,d,h,e;b=c.createElement("script");b.type="text/javascript";b.async=!0;b.src=("https:"===c.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.0.min.js';d=c.getElementsByTagName("script")[0];d.parentNode.insertBefore(b,d);a._i=[];a.init=function(b,c,f){function d(a,b){var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]);a[b]=function(){a.push([b].concat(Array.prototype.slice.call(arguments,0)))}}var g=a;"undefined"!==
typeof f?g=a[f]=[]:f="mixpanel";g.people=g.people||[];h="disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config people.set people.increment".split(" ");for(e=0;e<h.length;e++)d(g,h[e]);a._i.push([b,c,f])};a.__SV=1.1})(document,window.mixpanel||[]);
mixpanel.init("MYKEY");</script><!-- end Mixpanel -->

Here, MYKEY is my actual key.

Now, I want to see page views for each of my blog posts. I am putting following code in page.php, which gets called each time a post is viewed (afaik).

    <script type="php">
      mixpanel.track("Viewed Post")
    </script>

But I am not getting any data back. Can someone please help me here?


Solution

  • MixPanel does not work well with Wordpress blog. I would use Google Analytics.