Google Analytics on Intranets and Development Servers / FQDN

Just a quick posting about using Google Analytics on pages that don’t use a fully qualified domain name.

If you’re using Google Analytics on a site with a URL like http://intranet/ or something like http://mydevserver:12345 it won’t work.

Specifically, the Google Analytics JS code will not send the tracking hit (__utm.gif) to the GA servers.

I don’t really know the specifics, but I’m guessing that the domain hashing code looks for at least one period in the hostname and won’t work if it doesn’t find one.

Two alternatives come to mind:

1. Use an IP address if one will work. If you’re testing on a local machine should work fine (that IP always resolves to the machine you’re on)

2. Turn off domain hashing. Simply using _setDomainName("none") in your code should also fix the issue.

Hope that helps someone who might be pulling their hair out trying to figure out why the page is not being tracked :)