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 127.0.0.1 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 :)

7 thoughts on “Google Analytics on Intranets and Development Servers / FQDN

  1. Pingback: Google Analytics on Intranets and Development Servers / FQDN … | SFWEBDESIGN.com

  2. Pingback: Google Analytics GIF request not sent | PHP Developer Resource

  3. Pingback: Resolved: Can you test google analytics on a localhost address? #development #answer #solution | IT Info

  4. How is this set up in GTM. Can we create a custom tag instead of using the Universal Analytics Tag Type built in? However our Intranet is also an extranet & can reach the js script externally. How do I track the internal host which has no domain extension via GTM?

  5. I’m having no problems gathering data, as that code is on an internet domain. But I’m trying to test embedded reports on an admin page on localhost. and i’m getting cross-origin framing error. Load denied by X-Frame-Options… “NetworkError: 401 Unauthorized – https://accounts.google.com…..”

Leave a comment