1
votes

According to the Google Analytics docs if you want to collect analytics data when running an app on localhost you should replace

ga('create', 'UA-XXXX-Y', 'auto');

with

ga('create', 'UA-XXXX-Y', 'none');

When using the latter, will analytics data also be collected on "normal" domains, e.g. www.example.com, or will it only work on localhost?

1

1 Answers

0
votes

You should pretty much always be using auto, even when running on localhost. The section you linked to in the docs was written prior to the auto feature (automatic cookie domain configuration) being added to analytics.js

You can confirm that auto works on regular domains as well as on localhost by using your developer tools to see that a _ga cookie is successfully written.