TUTORIAL: Filtering Yourself from Google Analytics
-
Google Analytics is a powerful and useful tool for anybody with any kind of website who wants to track, in granular detail, their traffic. Furthermore, if you are into Google’s various revenue streams for traffic, its essential. But there is a huge problem for most people, the documentation sucks. I refer to their reference about how to exclude yourself, or any other people working on your site that you do not want to count, “How do I exclude my internal traffic from reports?“
The section most relevant to WordPress users is at the bottom, “To exclude traffic by Cookie Content” This is the method required for dynamic websites. Unfortunately, the information is sparse. Also, I have discovered that the explanation is deprecated and incorrect.
I had asked in the forums about this problem, “Google Analytics and WordPress” I received a number of helpful answers and I installed,”Yoast GA plugin.” The problem with the Yoast plugin and I would believe the other 2 would be that is almost impossible to solve this issue from within WordPress. It has to be solved on a per computer/user basis.
I am going to attempt to show exactly how to carry out this task, I promise to be gentle, some things are a bit technical. I want to credit my friend David Rosenfeld for doing most of the heavy lifting on this research.
1. First step, if you do not have a Google Analytics account, you need to create one. If you have a gmail account or some other Google account you can start with that.
2. You need to get the cut code snippet example and paste it into the header.php file of your of your WordPress site. Paste the snippet right before the line
</head>
Follow the other directions in Google help here, “Getting Started with the Asynchronous Snippet -The Snippet“3. Do not forget to get your Google Analytics Account ID here Overview ? WholeThinking ( Edit account settings ) while you are still logged into your account. Cut and paste that number into the code where it says, “UA-XXXXX-X” Once you have completed these steps you can save and close your header.php file.
4. Go to “Analytics Settings > Create New Website Profile” and create a profile, read more about that here, “Accounts and Profiles“
Let’s take a breath. You have now done everything needed to create a Google account, inserting the code snippet so that your site is followed and a Profile to do just that. If you did nothing else you could watch your site’s traffic and study all the nitty gritty details ad infinitum. But…
The whole point of WordPress is to keeping adding content. Whether you are the captain of your rowboat, acting as both admin and author, or run a site with multiple admins and authors you need to make sure that all of these contributors are not counted in Google Analytics. You and all your contributors will skew your data, giving you inaccurate results. 10 to 1, that huge readership in your hometown, is you working on your site, not other viewers. So let’s get you out of there…
You need to accomplish 2 things: create a filter in your GA profile that catches you and cookie on your computer that tags you in such a way that the filter sees you as unique from viewers. Let’s do the hard part first, creating the cookie.
1. Use any text editing app you want, just make sure that you save it in Plain Text, not RTF or any proprietary format. Cut and paste the code located in the Pastebin example into your text doc.
2. You need to change 2 pieces of data in the code. On line 13, change “Account ID” to your GA account ID. On line 26, change “your_value_here” to some unique value of your creation. Keep it simple enough, nothing but letters, numbers and underscore. I am not sure if this is case sensitive.
3. Once you have replaced the data with your unique information, save the file with any name you want. Make sure the extension of the is .html Place the file anywhere in your site as long as it is under your domain, at root or in a subdirectory.
4. Go back to the first page of Google Analytics, in the lower right, under the “Website Profiles” list, click on the link “Filter Manager?” Here is where you create your exclusion filter. Click on “+ Add Filter”
5. Give it a meaningful name, click on “Custom filter” and leave it on the default “Exclude”. In the popup menu choose, “User Defined”. Place the exact value you put in your HTML file in the field, “Filter Pattern” Set “Case Sensitive” to what works best for you but your values must match exactly. Below, in “Apply Filter to Website Profiles” assign your filter to your profile. Don’t forget to click on the button, “Save Changes”
OK, everything should be set, now for the sexy part…
1. Only carry out the next actions for computers you want to NOT be counted in Google Analytics. In the location field of your browser, set the path to your HTML file, domain > sub directory > file name. Press enter, return on keyboard to load the page. If everything works you should see a charcoal background with orange letters saying, “google analytics cookie excluder” If you see this, the page should have worked and set the cookie on the computer you want excluded from GA. Don’t get rid of this page yet.
2. TEST. Go to the area of your browser that shows cookies. Search for the value you set in the cookie. If you find it the value is set.
3. Save a bookmark of your excluder page. In case you clear your cookies, this is a quick way to reset it. It is also a quick way to get to the place to cut and paste the link for others who work on your site that you also want excluded.
4. Testing to make sure you are being excluded in the GA report is a bit more complicated. First you need 24 hours to see the data. I am able to see that I am not counted because my site is brand new and announced. Being in a big town can make an existing site hard to test, being in a small town makes it easier.
If over a few days or week you are suspicious of your numbers and think your are still being counted. Go back and check everything, also make sure you did not miss any of your contributors, authors and admins. In my case that was 2 people with 4 machines, we had to set all of them.
——————————————————
A few notes on the file…Line 8, this insures that your file (which is a page) is not indexed by search engines.
Lines 30 to 44, You can modify this part in any way you wish. This is simple feedback. In our case, we have several sites on a managed VPS. We all contribute in different ways to each other’s sites. To insure that we hit the right page and set set the right cookie we place the domain name in line 36, replacing, “google analytics cookie excluder” If you make a mistake an set a cookie on the wrong machine, delete the cookie and it will be counted.
So I hope this helps. I fiddled about for almost 2 months before I got to this solution. I really encourage anyone who would like to improve or suggest further improvements to place them here as comments. If any future generations search for Google Analytics, here it all shall be.
Not that you would see this in action, but it iss buried in the backend of my site WholeThinking If you do go there, I will see it in my Google Analytics. ??
- The topic ‘TUTORIAL: Filtering Yourself from Google Analytics’ is closed to new replies.