Tuesday, 3 December 2013

How To Enable Jetpack Stats On MobilePress

Important: All scripts hosted on widcraft.googlecode.com don't work anymore because Google has blocked that SVN repository.
Almost every WordPress admins uses WordPress' Jetpack plugin on their site to connect and use WordPress.com feature on their self-hosted WordPress. There are a lot of great modules in the Jetpack plugin, but Jetpack Stats module is my personal favorite.

MobilePress is also a well known plugin to create a mobile friendly version of your WordPress. It allows custom themes and a few other mobile friendly settings. But Jetpack's stats module only tracks the desktop version of your site, not the MobilePress version.

Don't worry about this, as I have found a way to enable Jetpack's stats module on our MobilePress. Here is how:

  • First of all, enable Jetpack stats module on your WordPress. Now visit your WordPress website as a guest (without signing in).
  • Now right click & click on View Page Source to view the source code of your current page, and search stats.wordpress.com in the source code page. You'll find a code similar to this:

<script src="http://stats.wordpress.com/e-201349.js" type="text/javascript"></script>
<script type="text/javascript">
st_go({v:'ext',j:'1:2.6',blog:'YOURUNIQUEBLOGID',post:'0',tz:'-5'});
var load_cmc = function(){linktracker_init(YOURUNIQUEBLOGID,0,2);};
if ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
else load_cmc();
</script>

  • Copy your unique blog id from your unique Jetpack stats snippet and place it in the following code:

<script src="http://stats.wordpress.com/e-201341.js" type="text/javascript"></script><script type="text/javascript">
st_go({v:'ext',j:'1:2.5',blog:'YOURUNIQUEBLOGID',post:'<?php the_ID(); ?> ',tz:'-4'});
var load_cmc = function(){linktracker_init(YOURUNIQUEBLOGID,0,2);};
if ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
else load_cmc();
</script>

  • Now paste the above code in the footer.php (webroot / wp-content / plugins / mobilepress / themes / default / footer.php) file of your current MobilePress theme. That's IT!!

As you can see, there's only one difference in the above two codes. In the second code, I have replaced the current post id with <?php the_ID(); ?>, otherwise your Jetpack wouldn't count views for specific page, and all your visits would be counted as Homepage views or of a specific post.
Important: Check our new website TricksPanda.com for WordPress tutorials, plugins and more.
 
Powered by Blogger.