GNU/Linux, Open Source, Cloud Computing, DevOps and more...

5 ways to exclude your own visits from Google Analytics

26 comments

It is quite annoying that our Google Analytics traffic statistics are adversely affected by our own visits or those of any member of our team (internal traffic). Even more in early stages of websites, while still receives little traffic and our activity is a greater percentage compared to the total activity. Not only modifies appreciably the number of visits per se, but also the number of page views per visit, bounce rate and average time spent per user among many other parameters. This makes sense, as it is when we spend more time reviewing each and every one of our web pages or performing unfinished development tasks.

There exists different methods to prevent your own visits are tracked by Google Analytics. Each one has advantages and disadvantages, so there is no star method that can be recommended with no doubt in any situation. In this article I try to show you a collection of the most important and widespread methods focusing mainly on their pros and cons. At the end of each method I link to some other articles which explain in detail how to implement them.


Error: Your Requested widget " ai_widget-6" is not in the widget list.
  • [do_widget_area above-nav-left]
    • [do_widget_area above-nav-right]
      • [do_widget_area footer-1]
        • [do_widget id="wpp-4"]
      • [do_widget_area footer-2]
        • [do_widget id="recent-posts-4"]
      • [do_widget_area footer-3]
        • [do_widget id="recent-comments-3"]
      • [do_widget_area footer-4]
        • [do_widget id="archives-4"]
      • [do_widget_area logo-bar]
        • [do_widget id="oxywidgetwpml-3"]
      • [do_widget_area menu-bar]
        • [do_widget id="search-3"]
      • [do_widget_area sidebar]
        • [do_widget id="search-4"]
        • [do_widget id="ai_widget-2"]
        • [do_widget id="categories-5"]
        • [do_widget id="ai_widget-3"]
        • [do_widget id="ai_widget-4"]
        • [do_widget id="ai_widget-5"]
      • [do_widget_area sub-footer-1]
        • [do_widget id="text-4"]
      • [do_widget_area sub-footer-2]
        • [do_widget_area sub-footer-3]
          • [do_widget_area sub-footer-4]
            • [do_widget_area upper-footer-1]
              • [do_widget id="search-2"]
              • [do_widget id="recent-posts-2"]
              • [do_widget id="recent-comments-2"]
              • [do_widget id="archives-2"]
              • [do_widget id="categories-2"]
              • [do_widget id="meta-2"]
            • [do_widget_area upper-footer-2]
              • [do_widget_area upper-footer-3]
                • [do_widget_area upper-footer-4]
                  • [do_widget_area widgets_for_shortcodes]
                    • [do_widget id="search-5"]
                    • [do_widget id="ai_widget-6"]
                  • [do_widget_area wp_inactive_widgets]
                    • [do_widget id="wpp-2"]
                    • [do_widget id="text-1"]
                    • [do_widget id="recent-posts-3"]
                    • [do_widget id="categories-3"]
                    • [do_widget id="archives-3"]
                    • [do_widget id="icl_lang_sel_widget-3"]

                  1. Server side or backend method

                  This is my favorite method, but its implementation is not feasible in all cases. It consists in preventing the Google Analytics tracking code is included within the HTML code returned by the server when you request a page from your own website. For example, you can configure your server to not include the tracking code when the source IP address is that of your office or home.

                  Google Analytics javascript tracking code

                  Pros
                  • It is the safest and most reliable method, since it is physically impossible for a visit to be recorded if there is no tracking code at all.
                  • You have absolute control over which visits count and which not, so you don’t depend on any oversights or omissions from your employees or collaborators as in other methods described below.
                  • It allows use of public IP addresses both fixed and dynamic, so it is a suitable method for organizations of all sizes and for individual users.
                  • Suitable for all kinds of browsers and devices, whether desktop PCs, tablets or mobile phones.
                  Cons
                  • It will not work properly if you have enabled a caching system that displays a static version of the pages visited. You can solve this problem by having non-cached pages to be displayed when it comes to internal views. Depending on how your application and caching system is built this solution may or may not be viable. If you contact me I can tell you if this solution is suitable for you or not and help in its implementation.
                  Implementation

                  2. Google Analytics filtering

                  Consists in using Google Analytics filtering feature which allows you to exclude visits based on a lot of different parameters such as IP address or source domain, search terms, page titles, etc. For our purpose filtering by IP address or source domain is the ideal choice, as it will allow you to exclude all traffic from your office, for example. Therefore it is a good method for small or large companies that can afford a fixed IP address for their Internet connection, and it is better the larger the size of the company and the number of its geographical locations.

                  Filter traffic by IP

                  Pros
                  • Google’s native solution, reliable and flexible.
                  • Allows full control on exclusion parameters.
                  • Suitable for any size companies and organizations provided they have fixed public IP address.
                  Cons
                  • Does not allow dynamic IP addresses, so it is not suitable for most small organizations or individual users as bloggers, for example.
                  Implementation

                  3. Google Analytics filter based on a cookie-stored custom var

                  Consists of installing a special cookie that does not expire and has a unique name that will help you to differentiate your own browsers which have this cookie installed (internal traffic), from those belonging to other visitors.

                  Exclude visits by cookie custom value

                  Pros
                  • Simple and flexible solution.
                  • Works on all browsers and all devices, including mobile phones and tablets.
                  • It works properly with dynamic IP addresses, so it is suitable for all users.
                  Cons
                  • Can be quite expensive, because you have to make an effort to set the exclusion cookie in all browsers on all devices that you will use. This effort may be excessive if your team is made up of many people who in turn use a variety of devices.
                  • The reliability of this method is not very high, as it doesn’t prevent internal users can delete their browser cookies and then forget to reinstall the exclusion cookie, or forget about installing it when starting to use a new device. You can alleviate the problem by using the localStorage feature of HTML5, since the values you store there do not expire or get deleted when you remove cookies from your browser.
                  • In order to increase reliability you’ll have to increase your effort, and therefore cost, as you’ll have to regularly review the exclusion cookie is present in all corporate devices. So it is a solution only suitable for small organizations and individual users.

                  Error: Your Requested widget " ai_widget-6" is not in the widget list.
                  • [do_widget_area above-nav-left]
                    • [do_widget_area above-nav-right]
                      • [do_widget_area footer-1]
                        • [do_widget id="wpp-4"]
                      • [do_widget_area footer-2]
                        • [do_widget id="recent-posts-4"]
                      • [do_widget_area footer-3]
                        • [do_widget id="recent-comments-3"]
                      • [do_widget_area footer-4]
                        • [do_widget id="archives-4"]
                      • [do_widget_area logo-bar]
                        • [do_widget id="oxywidgetwpml-3"]
                      • [do_widget_area menu-bar]
                        • [do_widget id="search-3"]
                      • [do_widget_area sidebar]
                        • [do_widget id="search-4"]
                        • [do_widget id="ai_widget-2"]
                        • [do_widget id="categories-5"]
                        • [do_widget id="ai_widget-3"]
                        • [do_widget id="ai_widget-4"]
                        • [do_widget id="ai_widget-5"]
                      • [do_widget_area sub-footer-1]
                        • [do_widget id="text-4"]
                      • [do_widget_area sub-footer-2]
                        • [do_widget_area sub-footer-3]
                          • [do_widget_area sub-footer-4]
                            • [do_widget_area upper-footer-1]
                              • [do_widget id="search-2"]
                              • [do_widget id="recent-posts-2"]
                              • [do_widget id="recent-comments-2"]
                              • [do_widget id="archives-2"]
                              • [do_widget id="categories-2"]
                              • [do_widget id="meta-2"]
                            • [do_widget_area upper-footer-2]
                              • [do_widget_area upper-footer-3]
                                • [do_widget_area upper-footer-4]
                                  • [do_widget_area widgets_for_shortcodes]
                                    • [do_widget id="search-5"]
                                    • [do_widget id="ai_widget-6"]
                                  • [do_widget_area wp_inactive_widgets]
                                    • [do_widget id="wpp-2"]
                                    • [do_widget id="text-1"]
                                    • [do_widget id="recent-posts-3"]
                                    • [do_widget id="categories-3"]
                                    • [do_widget id="archives-3"]
                                    • [do_widget id="icl_lang_sel_widget-3"]
                                  Implementation

                                  4. Browser extension

                                  Consists of installing your browser an extension which blocks the Google Analytics tracking script in order to not count your own visits. There are this kind of extensions available for almost all browsers, including one authored by Google. However the latter is too restrictive and blocks the tracking code from all websites you visit, which would disrupt other third party sites that have nothing to do with you.

                                  There are better extensions, but only work in certain browsers.

                                  GA blocking extension for Google Chrome

                                  Pros
                                  • Some extensions work well and fulfill its purpose perfectly.
                                  • Simple solution for small groups and individual users.
                                  Cons
                                  • Normally you have to install different extensions for different browsers.
                                  • If you have a large number of work places used to visit your own website (i.e. a company with many employees), managing the installation and maintenance of these extensions can be costly in time and effort.
                                  • Medium-low reliability, because it’s not easy to control someone using a different browser, or disabling the extension for some reason. If you ever visit your website from another computer or browser that does not have the extension installed, then the visit will be recorded.
                                  • Extensions consume browser resources, and therefore computer resources.
                                  • Normally tablet and mobile browsers do not support extensions., so this solution is only suitable for desktop computers.
                                  Implementation

                                  5. Add a variable to your web address stating that visit not to be tracked

                                  This method is very unreliable but may be of interest in certain scenarios, such as development or testing environments. It involves accessing your website by placing an extra URL variable to state you don’t want that visit to be tracked. There are two modes: the server interprets the variable to not include the tracking code within the response’s HTML code, or the tracking script is blocked into the user’s browser using extra javascript code.

                                  https://www.yoursite.com?test=1
                                  
                                  <?php
                                  if (!isset($_GET['test’]))
                                  {
                                  ?>
                                  <!--PUT GOOGLE TRACKING CODE HERE-->
                                  <?php } ?>
                                  
                                  Pros
                                  • You can control at all times which visits are to be tracked and which not, which may be useful in testing environments.
                                  • It is relatively simple to implement.
                                  Cons
                                  • You can’t control other members of your team will always remember to properly set the URL variable before accessing the site when you don’t want the visit to be counted.
                                  • In fact it is a rather awkward method even for ourselves and we can also make mistakes or forget to set the variable.
                                  • You must implement a mechanism to preserve the variable each time you jump to another page on your website by clicking on a link, i.e. using session variables or cookies.
                                  Implementation
                                   

                                  About the author

                                  Daniel López Azaña
                                  Freelance AWS Cloud Solution Architect & Linux Sysadmin

                                  Entrepreneur, a generator of ideas and restless mind. Passionate about new technologies, especially Linux systems and Open Source Software. I also like to write about Technology News, Cloud Computing, AWS, DevOps, DevSecOps, System Security, Web Development and Programming, SEO, Science, Innovation, Entrepreneurship, etc.

                                  Daniel5 ways to exclude your own visits from Google Analytics

                                  Related Posts

                                  26 comments

                                  Join the conversation
                                  • Alivia Smith - 04/02/2015 reply

                                    Great article ! Very helpful.
                                    Quick question though : how can I block my own visits and uses of the app we developped ? it can only be used on an iphone so if I understand properly I don’t think any of the methods above work in that case, ideas ?
                                    I would really appreciate an answer, Google wasn’t much help with this one…

                                  • Mathieu - 19/03/2015 reply

                                    Hi,

                                    I thought of another approach using HTML5’s localStorage feature. The advantage over the cookie is that when you clean your browser’s cookies, localStorage values remain.
                                    I’ve written a blog article about it here:
                                    http://www.mendoweb.be/blog/google-analytics-exclude-your-own-visits/

                                  • ohm - 09/04/2015 reply

                                    Great tips!!! Thank you so much. Btw, I love the solution that use add-on. Hope it works for me.

                                  • Guillermo - 21/07/2015 reply

                                    I found myself in this same dilemma not long ago. Didn’t want to hard code anything because I only wanted to filter the admins during certain periods of time and altering the code over and over would be a headache. IP filtering didnt work as our team was working from many different locations with dynamic IPs… Then plugins such as Yoast and others had way too many options for my simple goal… so I created this plugin

                                    http://codecanyon.net/item/google-analytcis-by-users-and-roles/12168848?ref=mirlostudio

                                    It will add your GA code to all pages and give you the option not to track handpicked users or roles.

                                    Hope somebody will find it useful! 🙂

                                  • Ali - 04/09/2015 reply

                                    The first solution excluding the code from the back-end seems the best for me, since i don’t have caching set up, this is was very helpful i should have though of this solution before searching. Thanks

                                  • Syed - 05/11/2015 reply

                                    Hi Dan,

                                    How about if my IP changed certain time?

                                    John - 19/12/2015 reply

                                    Use cookies from all your machines. I may suggest you to have a cookie that become true if or when you’re entered to the site as an admin. And then all you need is to read this cookie and whether execute GA counter code in your script or not.
                                    As simple as that.
                                    P.S. Sorry for English

                                  • Michael Herrmann - 05/03/2016 reply

                                    Thanks for the interesting article! I manage several client accounts and had to perform the steps you describe in “Google Analytics Filtering” so often that I created an open source tool that performs them automatically. It creates an exclusion filter for the IP you visit it with at the click of a button. It’s open source and 100% free. You can find it at https://www.excludemyip.com. Would love to hear your thoughts!

                                    Cheers
                                    Michael

                                  • Vikas - 12/04/2016 reply

                                    Thanks for the valuable info bro.

                                    I will be using browser extension method. But how can the reliability of the extension be checked?
                                    One more thing I want to ask. Will the cache problem be avoided if I use Inprivate browsing like Incognito window in chrome ?

                                    Daniel - 05/05/2016 reply

                                    You should keep Google Analytics Real Time screen open while you click a couple of links on your website. If your visit is not registered by Google Analtics within a few seconds, then your extension is working properly.

                                    The incognito windows in Chrome is supposed to avoid cache problems as it always reloads all the content and resources within every request. BUT, in my experience, this is not always true, and I had several cache problems in the past despite navigating through the incognito window. Only when you explicitly clear the cache and all navigation data from Chrome you can be sure that all the content and resources are fresh.

                                    Tony - 09/11/2016 reply

                                    Hi there,
                                    I used the IP filtering within the Google analytics console as a more simple method. I then followed your advice on having ‘Realtime’ analytics open and visited 2 pages of my site. I could almost immediately see them in the Real time window.
                                    Does this mean that despite the filtering of my IP to be excluded it still records it?
                                    Thank you for any input..

                                  • Alcides - 13/04/2016 reply

                                    I like a lot your method #1. It’s used by default with ShimmerCat’s SOCKS5 proxy when developing…. For the real website however all the methods are kind of awkward and taking for our crew. The best we have done is to filter out entire cities (where our team lives) from some of the reports…. Not ideal, because we also enjoy some popularity in our little town.

                                  • VincyB - 12/05/2016 reply

                                    You can use VPN/proxy service like HIDE-MY-IP. They mask your true IP by letting you to choose which IP and from what country you want. That way Google won’t recognize your real IP. I would recommend you using HIDE-MY-IP VPN, they offer great service.

                                  • Sarah - 09/08/2016 reply

                                    Google analytics counter tracker is my favourite plugin.It’s simple and easy to use.
                                    https://wordpress.org/plugins/analytics-counter/

                                  • zainab - 31/08/2016 reply

                                    Thanks for the article. For good analytics use ttps://wordpress.org/plugins/analytics-counter/

                                  • Prosper - 30/09/2016 reply

                                    Well said, am also using the Same plugin for Google Analytics Counter Tracker..

                                  • MARCO - 04/03/2017 reply

                                    Hi Daniel,
                                    anything on excluding your device from analytics APP tracking?

                                  • Rick - 24/10/2017 reply

                                    What about using incognito method?

                                  • Daniel - 24/10/2017 reply

                                    Hi Rick, unfortunately, the incognito method doesn’t prevent Google Analytics from tracking your activity within a website, since the analytics.js script still works even in incognito mode. In my opinion, it’s actually worse for statistics because every time you visit the website you’ll be considered a different unique user instead of grouping your multiple visits into a single user.

                                  • John - 21/06/2018 reply

                                    Great tips! Thanks!

                                  • Zac - 31/08/2018 reply

                                    Great article on an important topic. What do you think about using the User Explorer to look at Client IDs with hundreds of sessions, on the assumption that they are staff (working in multiple locations with dynamics IPs)? This obviously wouldn’t work for some companies like SaaS or major online retail that would have real external users with high numbers of sessions…

                                    If this strategy holds water, I’d love to hear your thoughts on how to filter out, say, the top 20 users with the highest number of sessions.

                                    Daniel - 31/08/2018 reply

                                    Thanks Zac! Every method is good if it fits the reality of your business or your website. For example, I have users who visit my website over and over again looking for the same article or a very small group of articles. I guess that’s because they are useful for their daily work, and if I were to rely on your approach I’d be excluding legitimate visits. So it depends on your specific case, if you are sure that those users who visit your site hundreds of times are employees or collaborators, then go ahead.

                                  • 3Rascals - 08/07/2019 reply

                                    How to do it with WordPress websites? Any plugins?

                                  • Allan - 12/07/2020 reply

                                    Google should exclude the user by Gmail account. You do not have to log into Google Analytics since Google recognizes your Gmail account with the website your associated with. It seems that I can exclude myself only based on the dynamic IP address which is a pain to exclude by changing the exclude option all the time. Most Web hosting sites have their own analytics for your site. If they start to give analytics based on what users want to see you can kiss Google Analytics good-bye.

                                  • Kelly Hubbard - 02/09/2021 reply

                                    Great post, but you said Chrome is the world most popular browser. That is Google’s aim to be the only browser. Remember when Google’s logo was “”We won’t be evil.””? Too late now. Soon Chrome will force web developers to build in code to slow down Firefox or Duck Duck Go. Like Microshit did with Wordperfect.

                                  • Alex - 08/12/2021 reply

                                    What about excluding by campaign?

                                    Unfortunately from my tests it doesn’t work. Did anyone made it work ?

                                  Leave a Reply

                                  Your email address will not be published.