I have a site, www.example.com, that displays some secure content from forms.example.com in iframes. To enable cross-frame navigation, pages on both sites use JavaScript to set the document.domain to just "example.com".

I am using Google Analytics on www.example.com, but the GA site is not showing any data. It indicates that the tracking code is found (the status icon is a green checkmark), but no data is reported.

The GA profile lists the website as "www.example.com".

Is this a supported scenario? Is my script interfering with the GA code in some way?

  • Has your question not been answered yet? – Christopher Feb 14 '11 at 19:21

A search of ga.js would suggest that the string "document.domain" (or the minified variant "E.domain") does not, in fact, appear.

It would appear as though Google Analytics uses window.location.hostname (encoded as b.hostname) to get the domain.

|improve this answer|||||
  • I know that setting the doc domain has security implications for scripts, so I was really wondering if doing so would create an error condition that would prevent the GA script from "phoning home" to the stats server. Thanks for the answer though, it might be helpful. – Seth Petry-Johnson Nov 7 '10 at 1:51
  • @Seth_Petry-Johnson - You can get all the information Google has by watching the traffic in your browser when the ga.js script phones home and by looking over the ga.js script itself - the Live HTTP Headers and Firebug extensions for FireFox should help with debugging... all that's left is to test :) – danlefree Nov 7 '10 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.