Wednesday, April 11th, 2007...8:28 am
How To Stop Stat Trackers From Counting Your Hits
If you visit your own site alot like I do, you’ll quickly find you skew your stats with all the extra pageviews and hits. There is an easy way to stop that from happening.
If you’ve played around with Wordpress a bit you’ll know it has different user levels. The most powerful user level is that of admin, which is level 10. Assuming your login is set to “Remember Me”, this is always going to be you, so it’s a simple matter of inserting some php code to check if the current user is level 10 (you), and if it is then the stats code doesn’t get loaded.
The following is the code you can use.
<?php
get_currentuserinfo();
global $user_level;
if ($user_level != 10) {
echo "
PUT YOUR STATS CODE HERE
";
}
?>
Update:
This is why you shouldn’t write at 3am. You forget things. Some people have been getting parsing errors when they use this code. I forgot to mention you need to add a back slash \ before any quotation marks (” or ‘) in the stats code you paste in. Sorry about that.
Update #2:
I figured out why some of you were still getting parse errors. This time it wasn’t my fault. It was due to the way Wordpress was formatting the quotation marks. I’ve made another change to the code, and now you should be good to go.










4 Comments
April 11th, 2007 at 11:05 pm
I still get the error.
April 11th, 2007 at 11:11 pm
Syaf if you want send me the code you’ve got and I’ll have a look. You can send it to me here.
April 12th, 2007 at 7:30 am
I can’t resist saying this because I know many people are thinking it:
“It only skews the tracking stats if you are the only one reading your blog!”
April 17th, 2007 at 2:12 am
The stats counter I use allows me to block myself as a visitor so I just do that. I track several blogs using that counter and it works.
By the way - found you on Duncan’s recent post about Aussie Bloggers. I’m in Melbourne and manage a number of blogs but only one has ‘Australian’ content. All the rest are business or personal interest topics.
Leave a Reply