Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test Google Analytics on Localhost

Tags:

I need to test some custom firing events using Google Analytics. I'd like to test in a local environment.

I've set up my test site using apache with server name: my-ga-test.localhost/

According to Can you test google analytics on a localhost address? and Google Analytics docs, I'm able to adjust my GA code to use:

ga('create', 'UA-XXXX-Y', {   'cookieDomain': 'none' }); 

I tried to set up a new account to get a tracking ID for this site, but I'm getting the following error:

URL ends with an invalid top-level domain name

enter image description here

How do I generate the code using localhost domain so I can alter the tracking ID code to put on my localhost?

like image 975
user3871 Avatar asked Jun 01 '15 19:06

user3871


1 Answers

The "Website URL" field when creating a new Google Analytics property does not have to be the same as the actual URL that's used in production. It's primarily used for resolving relative links, not for validating hits.

Just change it to something else (like example.com), and everything should work fine.

like image 166
Philip Walton Avatar answered Oct 12 '22 15:10

Philip Walton