Prevent wordpress admin to be tracked by Google analytics

November 22, 2008 · Print This Article

How can we’ll be able to prevent the blog admin from being tracked as a normal visitor by Google Analytics or any other tracking code.

We need the current_user_can() WordPress function. This function checks the given parameter, which is the level of the current user, and returns true if the level of the current user is superior or equals to the given parameter.

The following code will track any visitor or blog contributor exept the admin, if he’s logged in, of course.

if (!current_user_can('level_10')){ ?>
<?php } ?>

Your choice for site templates and wordpress themes


Got something to say?

You must be logged in to post a comment.