Register now and start sharing your code snippets.
-->

How to exclude your own traffic from Google Analytics reports and other JavaScript based analytics software

Ruby posted 4 months ago by christian

Option 1: Changing your browser’s user agent

Open the about:config page in Firefox by typing about:config in the address bar and pressing enter. Now change the general.useragent.extra.firefox setting to an easily identifiable string, for example the following:

   1  Firefox/3.0 disable-tracking

Then in your code check that the user-agent string doesn’t contain disable-tracking>

   1  <% if !request.user_agent.include?('disable-tracking') %>
   2  TRACKING CODE GOES HERE
   3  <% end %>

Option 2:

Use one of Google Analytics native ways of excluding traffic from certain domains, IPs, user-agents or users having a specific browser cookie.

Tagged google, analytics, tracking, exclude, traffic