2

I have a conceptually simple problem involving Google Analytics and Tomcat, but I cannot solve it.

We have Google Analytics set up for our production machine and it is working fine. I want to set up a Google Analytics account to monitor our test system so I can test various features without affecting/polluting our production data. I have a test system set up, and a test Google Analytics account. However, the test Google Analytics account never receives data from the test system.

From my investigation, it appears that the problem is that my test system is being referred to as "localhost" instead of "test.mycompany.com" and the document.domain property used by Javascript is therefore "localhost" instead of the "test.mycompany.com" URL that it should be. This is causing the Google Analytics cookies to be written incorrectly (I think) and therefore the Google Analytics Javascript code is never sending data to my Google Analytics account.

Is there any way to set this "document.domain" property in Tomcat 6 so that this system will think it is "test.mycompany.com" instead of "localhost"?

I have examined both the Tomcat docs and the Google Analytics docs, but neither of them address this point directly.

Any help would be appreciated.

user1071914
  • 3,295
  • 11
  • 50
  • 76

2 Answers2

1

Open your firewall on the test server so google can access it and use add this in the snipet

_gaq.push(['_setDomainName', 'none']); //has to be place before _trackPageview

also open your firewall for ga

https://ssl.google-analytics.com/__utm.gif
http://www.google-analytics.com/__utm.gif

and

http://www.google-analytics.com/ga.js

So, port 80 for HTTP, port 443 for HTTPS and the site(s):

ssl.google-analytics.com
www.google-analytics.com
Scriptor
  • 1,125
  • 1
  • 6
  • 13
  • Oh and chrome + this addon: https://chrome.google.com/webstore/detail/jnkmfdileelhofjcijamephohjechhna So you can test the results directly. – Scriptor Apr 25 '12 at 15:37
  • Thanks but getting our network people to change a firewall is next to impossible - I will have to figure something else out. – user1071914 Apr 25 '12 at 15:56
  • Run it on the same web server in a different folder/subdomain? – Scriptor Apr 25 '12 at 16:08
  • It turned out to be this problem: http://stackoverflow.com/questions/9738815/google-analytics-gif-request-not-sent/9741228 – user1071914 Apr 25 '12 at 16:32
1

See stackoverflow.com/questions/9738815/google-analytics-gif-request-not-sent/9741228

Google Analytics doesn't send the tracking GIF for localhost, unless

_gaq.push(['_setDomainName', 'none']);

is added before the _trackPageview

Community
  • 1
  • 1
mike
  • 7,137
  • 2
  • 23
  • 27
  • That was the problem! Thanks. The reference to the other issue was a huge help also. Part of this problem was not knowing exactly what the issue was, therefore not being able to search for the answer. This did the trick. – user1071914 Apr 25 '12 at 16:30
  • Ah yes, i forgot in my post to say it has to be before trackpageview. :) – Scriptor Apr 25 '12 at 16:39