Title: Top 10 2.x &#8211; Tracking fix
Last modified: August 22, 2016

---

# Top 10 2.x – Tracking fix

 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/)
 * All,
 * In case you’re noticing that the plugin isn’t tracking all visits, you could 
   try to add this piece of code to your themes functions.php file at the very bottom.
   This code attempts to restore the original tracker that was used in previous 
   versions of Top 10.
 * If your theme’s functions.php file has the closing php tags i.e. `?>` then add
   this just before the closing tag.
 *     ```
       function filter_tptn_add_counter_script_url( $home_url ) {
       global $tptn_url;
       return $tptn_url . '/includes/top-10-addcount.js.php';
       }
       add_filter( 'tptn_add_counter_script_url', 'filter_tptn_add_counter_script_url' );
       ```
   
 * If you’re running this piece of code, I’d appreciate a bit of feedback on the
   quality of tracking.
 * [https://wordpress.org/plugins/top-10/](https://wordpress.org/plugins/top-10/)

Viewing 15 replies - 1 through 15 (of 32 total)

1 [2](https://wordpress.org/support/topic/top-10-2x-tracking-fix/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/top-10-2x-tracking-fix/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/top-10-2x-tracking-fix/page/2/?output_format=md)

 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640687)
 * Additionally, few things to check if the tracking is working:
 * 1. Try enabling Cache Fix option in the Top 10 Settings page
 * 2. Clear all caches from plugins like W3 Total Cache, WP Super Cache, etc. Also
   clear caches from server based caching like Varnish
 * 3. Log out from your site dashboard, so WordPress treats you as a normal user
   and visit your posts pages. View the source of the page and search for “activate_counter”.
   It should be part of the code which has `jQuery.ajax` as well.
 *  [coldpumpkin](https://wordpress.org/support/users/coldpumpkin/)
 * (@coldpumpkin)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640689)
 * I’ve been trying to find the most suitable plugin for me and I just downloaded
   this one. Noticed it’s not tracking any visits at all and came here and found
   this post. Tried the above solutions but it still isn’t keeping track of my visits.
   Even if I log out from admin.
 * EDIT: I don’t have any WP Cache plugins and I left the settings untouched, except
   the “Track visits of authors on their own posts?” which I enabled. Added `<?php
   if ( function_exists ( 'echo_tptn_post_count' ) ) echo_tptn_post_count(); ?>`
   to my single.php and it says “(Visited 1 times, 1 visits today)”. Refreshing 
   the page won’t do anything. If I enable “Always display latest post count”, it’ll
   show “No post visits”.
 *  [HeliR](https://wordpress.org/support/users/helir/)
 * (@helir)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640692)
 * I traced it today by putting “automatic output on page / post” in the top10 settings.
 * It outputted the real hits.
 * I could later trace it to some SQL-selection bug in top10 that I documented in
   a [support post](https://wordpress.org/support/topic/counter-bug-more-detailled?replies=2)
 * In addition I suggest you to have a look at [this shortcode I posted here](https://wordpress.org/support/topic/super-shortcode-for-top10?replies=1),
   it allows you to view the page-hits (counted by topten) with a shortcode in the
   footer or sidebar or within the post without messing in the source of the theme.
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640696)
 * [@coldpumpkin](https://wordpress.org/support/users/coldpumpkin/), what is your
   site URL? Do you see the counts working in the backend?
    I assume you’re using
   v2.0.3?
 * [@helir](https://wordpress.org/support/users/helir/), I responded to your other
   post.
 * Please see this post for a fix to get the blog_id 0 items changed to blog_id 
   1
 * [https://wordpress.org/support/topic/counters-not-shown-properly-since-v2-update?replies=21#post-6392699](https://wordpress.org/support/topic/counters-not-shown-properly-since-v2-update?replies=21#post-6392699)
 *  [coldpumpkin](https://wordpress.org/support/users/coldpumpkin/)
 * (@coldpumpkin)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640707)
 * [@ajay](https://wordpress.org/support/users/ajay/) I’m using at localhost right
   now, but I just installed the plugin freshly really. Latest version. The counts
   don’t appear in the backend aswell.
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640710)
 * Can you post a screenshot of your settings page. It’s a bit difficult for me 
   debug since it is on localhost.
 * Have you tried viewing the source of the page to see if activate_counter is present?
   Did you see the link solution I posted in my previous response?
 *  [coldpumpkin](https://wordpress.org/support/users/coldpumpkin/)
 * (@coldpumpkin)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640718)
 * Actually it’s weird, I installed a fresh wp with the plugin alone and it’s working.
   In my localhost the activate_counter is not present! Also, disabled all other
   plugins and still, nothing.
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640719)
 * That is actually good news! Though, I haven’t seen any issues with localhost,
   because I run my base development there.
 * For the localhost version, can you reset the top 10 settings to default or alternatively,
   delete and reinstall the plugin.
 *  [coldpumpkin](https://wordpress.org/support/users/coldpumpkin/)
 * (@coldpumpkin)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640720)
 * I’ve done that, still nothing! Tried switching themes, and it works in WP’s defaults!:
   O What could be wrong with my theme? What I did basically was adding `<?php if(
   function_exists ( 'echo_tptn_post_count' ) ) echo_tptn_post_count(); ?>` in single.
   php
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640721)
 * If it’s working with other themes, it is a good step forward.
    Does it work with
   non-default themes other than your current one?
 * If my understanding is correct, ideally your theme should be using `the_content`
   to display the content which is what triggers the filter to add the counter text
   in.
 * You might want to verify this by installing e.g. my related posts plugin and 
   seeing if they display in the post content
 * [https://wordpress.org/plugins/contextual-related-posts/](https://wordpress.org/plugins/contextual-related-posts/)
 *  [coldpumpkin](https://wordpress.org/support/users/coldpumpkin/)
 * (@coldpumpkin)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640722)
 * Nah, I’m not using that tag. Shouldn’t the tag I inserted above work? Maybe there’s
   more being output to the_content needed for the plugin to work.
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640723)
 * The tag above is only to display the count, not the track it. The tracking is
   automatically done by adding in the necessary script (activate_counter) to [the_content](https://codex.wordpress.org/Function_Reference/the_content).
 * It usually forms the part of your theme which is why I am a bit surprised you
   don’t see it happen.
 * Worst case is to use this code as well. But, I definitely don’t recommend this
   on a production site.
 *     ```
       <?php echo tptn_add_viewed_count( '' ); ?>
       ```
   
 *  [coldpumpkin](https://wordpress.org/support/users/coldpumpkin/)
 * (@coldpumpkin)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640724)
 * The reason why I don’t use the_content is because I’m building a photo blog. 
   So basically all I need is the thumbnail. Adding that code made it work. What
   do you mean “production site”?
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640731)
 * Production site means your site that is active for the world to see.
 * If you’re not using the_content in the theme, then you would need to use the 
   above code. You should test to see if it works fine with your theme, but that
   would be the only option to ensure the tracking code gets added.
 *  [coldpumpkin](https://wordpress.org/support/users/coldpumpkin/)
 * (@coldpumpkin)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/#post-5640732)
 * Yes, it seems to be working just fine! Thanks for that. Also, on a unrelated 
   topic, any way to prevent inflated post views? Like someone who keeps refreshing
   the page causing the view count to get higher. Perhaps a timer or even track 
   by IP? Thanks again.

Viewing 15 replies - 1 through 15 (of 32 total)

1 [2](https://wordpress.org/support/topic/top-10-2x-tracking-fix/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/top-10-2x-tracking-fix/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/top-10-2x-tracking-fix/page/2/?output_format=md)

The topic ‘Top 10 2.x – Tracking fix’ is closed to new replies.

 * ![](https://ps.w.org/top-10/assets/icon-256x256.png?rev=2986432)
 * [WebberZone Top 10 — Popular Posts](https://wordpress.org/plugins/top-10/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/top-10/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/top-10/)
 * [Active Topics](https://wordpress.org/support/plugin/top-10/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/top-10/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/top-10/reviews/)

 * 32 replies
 * 8 participants
 * Last reply from: [WebberZone](https://wordpress.org/support/users/webberzone/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/top-10-2x-tracking-fix/page/3/#post-5640836)
 * Status: not a support question