Mobile app version of vmapp.org
Login or Join
Samaraweera270

: Does Google Analytics track localhost activity? 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

@Samaraweera270

Posted in: #GoogleAnalytics

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

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-12345678-9', 'auto');
ga('send', 'pageview');
</script>


Goal Conversion Script

<script>
window.addEventListener('load',function(){
jQuery('.happy-form')
.submit(function(){
ga('send', 'event','subscribe','clickSubmit','happyPlace');
});
});
</script>

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Samaraweera270

2 Comments

Sorted by latest first Latest Oldest Best

 

@Reiling115

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.

10% popularity Vote Up Vote Down


 

@Megan663

I believe that to track on localhost, you could also set your trackers cookie domain to none (auto works, too, cf. 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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme