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

About these ads

About Ophir Prusak

Web Analytics and Optimization Expert

3 Responses to “Google Analytics on Intranets and Development Servers / FQDN”

Trackbacks/Pingbacks

  1. Google Analytics on Intranets and Development Servers / FQDN … | SFWEBDESIGN.com - January 23, 2011

    [...] Excerpt from:  Google Analytics on Intranets and Development Servers / FQDN … [...]

  2. Google Analytics GIF request not sent | PHP Developer Resource - May 23, 2012

    [...] Google Analytics on Intranets and Development Servers for more [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 69 other followers

%d bloggers like this: