I want to know if Google Analytics is tracking my localhost activity.

We have the below GA tracking script on each page and are developing new features on our local machines. Is Google tracking our visits, sessions, and goal conversions?

Tracking Script

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  ga('create', 'UA-12345678-9', 'auto');
  ga('send', 'pageview');

Goal Conversion Script

              ga('send', 'event','subscribe','clickSubmit','happyPlace');
  • Have you looked in your real time stats?
    – Howard E
    May 13 '16 at 0:12
  • Thanks for the suggestion! I will have to test this out with Goals.. (that is my main concern)
    – Rastalamm
    May 14 '16 at 18:31
  • Real time data is unfiltered, so it's good for testing goals and events
    – Howard E
    May 14 '16 at 18:36
  • @HowardE, wanted to mention that filters ARE indeed applied in RT reports. The only time RT data is unfiltered is if you don't have filters for that particular view.
    – nyuen
    May 14 '16 at 19:02
  • Check if any of browser plugins is blocking. Open the browser in incognito mode. May 24 '19 at 12:58

Go to Admin in Google Analytics, in the third column click on Filters.

Add a filter that only includes the hostname you do want to track, that way anything else, include localhost, will be excluded from your data going forward.

It's not possible to correct data that has already been gathered.


I believe that to track on localhost, you could also set your trackers cookie domain to none (auto works, too, cf. https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#automatic_cookie_domain_configuration). Install GA Debugger for Chrome to make sure the hits are sent and also to see valuable debugging info.

Edit (based on comment): I'm not sure how to prevent tracking in localhost, but if you do the converse of the above, and set your cookie domain to your top level domain (ie. example.com), then that shouldn't track your localhost.

  • I am trying to avoid being tracked in localhost
    – Rastalamm
    May 14 '16 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.