Installing & Troubleshooting Google Analytics 2013 (ga / analytics.js)
Setting up the new Google Universal Analytics (still in beta) is not completely obvious. You normally won't be able to send events from localhost and it will claim that "Tracking Not Installed." Here are some tips how to use Analytics from localhost and test it.
Enabling GA on a site running at localhost
You need to set cookieDomain to 'none' as suggested by BenSwayne as SO (see the docs):ga('create', 'UA-XXXX-Y', { 'cookieDomain': 'none' });
Testing GA
To check that GA works:- Enable GA from localhost as described above
- Open the Real-Time view in Analytics (GA - Reporting - Real-Time - Events) and
- In another window, open your webpage and use the Chrome Dev Tools' Console to send an event, f.ex.:
ga('send', 'event', 'my_ga_test', 'it is working!')
- In the Network panel of Chrome Dev Tools, you should see a GET request for
http://www.google-analytics.com/collect?...
- The event should appear on the dashboard in no/short time