Google Analytics Dashboard

Exclude Admins From Google Analytics on WordPress


Google Analytics is an incredible tool that can track a phenomenal amount of useful information about your visitors. However, when your site is new, or if you just happen to spend a lot of time on there yourself, your numbers will be skewed as they are tracking you, the site admin, as well.

There’s two simple workarounds that will allow you to continue collecting stats from your visitors, but ignore any logged-in users (note that you must be logged in for both of these methods to ignore you).

Using A Code Snippet

The cleanest method in my opinion is to add a little code snippet in your footer.php as it does not bloat your installation with a plugin:

Open up your theme editor so that you can edit footer.php. Find the wp_footer() call (shown in line 01 below) and add the remaining lines below it, substituting your own Google Analytics tracking code (available from your Google Analytics dashboard – hit Edit next to the site in question, and then Check Status on the next page) in the lines highlighted in grey (which is my own tracking code).

It’s a very simple piece of code which wraps your Google Analytics code in a conditional statement, which checks whether the user is logged in or not. If they are, it skips over the tracking code, otherwise it uses it as normal.

Using a plugin (Google Analytics for WordPress)

Ignore WordPress Users from Analytics

Ignoring logged-in users for Google Analytics by using Google Analytics for WordPress

The Google Analytics for WordPress plugin is the only plugin you need when it comes to using Analytics with WordPress. Among the many options is one to skip over tracking logged-in users. You can also specify which roles you want to track (Authors, Editors, Administrators etc.).

On your Settings Page (select Settings > Google Analytics from the menu at the side of your dashboard), scroll down to the Advanced Settings section and the very first option is the one you’re interested. Select the minimum role that you want your tracking code to ignore (i.e. selecting Subscriber will ignore all logged-in users, but selecting Administrator will only ignore those with Administrator privileges). Save your settings and you’re away.

I visit my own site a lot to check things over and make design changes, so I get a lot of page hits that in my opinion should be omitted. Are you in the practice of ensuring that logged-in users are not being tracked for Analytics?

Categories: Code & Snippets, Plugins | Permalink

What next?

Hire me

If you couldn't quite manage this yourself, find it too intimidating, or just don't have the time to do it, you can always hire Dave to do it. Please get in touch so that we can discuss your needs.

Leave a comment

If you have a question, update, or comment about the tutorial, please leave a comment. I try and respond to every comment, though it may take a few days, so please check back soon.

Let a WordPress Expert help you

Do you want to try this, but feel like you need a helping hand, in case something goes wrong? My service, The WP Butler, gives you access to WordPress expertise whenever you need it. Better yet, I'll keep your site backed up, updated and secure, so that you don't have to worry about it. It's all part of the service. Use coupon DIWW and save 15% on all plans.

Visit The WP Butler


Dave has been tinkering with WordPress for many years, and he now shares his WordPress knowledge here on Do It WIth WordPress to help others realise its impressive power. He can also be hired to help with your WordPress needs. Dave, who is British, is married to his best friend, Marti, with whom he has a beautiful daughter, Ellie. When he's not dabbling with WordPress, he's probably eating Triscuits or hummus, watching an indie film or British TV show, spending time with friends or family, or exploring the world.


  1. I think using plugin is the most sensible thing to do because the plugin offer far more advantages as well. This want be a big problem for an established site though

    • Well you’re right, you do have more options with the plugin, but you have to decide whether you really need them. It’s always better to hard code it if possible – it’s the cleanest way to do it and the least burdensome for your blog.

  2. Hi Dave, this is a great tip! I’m using a different plugin called Google Analyticator but it basically has the same options. Hmmm…. maybe I should do a screencast for that one! Do you also use the Filters options in GA? I filter out my visits by IP from my home computer and from my work computer.

    • Hi Ileane,

      I think you should definitely do a screencast of Google Analyticator. Then we could link to one another’s?

      I used to use the GA IP filter, but I also access my site on the go, so my iPhone has a dynamic IP and it’s impossible to filter it. But excellent point. Certainly a good option for many users.

  3. Awesome, thanks for this, i don’t use analytics much anymore, but i’ve found that in wordpress, you can just install the plugin and it will do it for you.

    • Hi Peter, nice to see you here. I remember seeing a blog post from you, maybe on BizChickBlogs?

      Anyway, while WordPress is awesome for that very reason, I try and avoid plugins where practical, because it’s much better practice to hard code features into your theme.

  4. I use Google Analyticator plugin to exclude logged in users. It is quite good and brings lot of other features to table too. However, one disadvantage of having code excluded is that you can’t use site overlay. I have to use different browser for that, a little sacrifice.

    • Yes, someone else mentioned the Analyticator plugin to me. And that’s a good point about being unable to use Site Overlay – that hadn’t even occurred to me, since I don’t use that feature yet, but it’s maybe I should think about looking into in the future.

  5. I do enjoy your ideas, thank you very much!

  6. Love the idea!!

    Have never thought about that, thanks!, tweeted!.

  7. What if you use a page cache system? Won’t this risk to generate a cached version without Analytics’ code?


  8. is this code still relevasnt with Universal analytics?

Leave a Reply