It is clearly documented in their help center:
Installing the Analytics tracking code on a site that uses frames requires some careful consideration to ensure that your traffic is tracked accurately, and that the referral information is retained.
We recommend that a site using frames includes the tracking code in the section of the frameset (parent) page, as well as directly before the tag of each child frame that you want to track. If you place your tracking code within a tag thinking that this is equivalent to the body, the code will not run and no data will be recorded.
If all frames on the site reside on the same domain, then referral information can be properly recorded as long as you've installed the tracking code on the first page users visit on the site.
The Solution:
- Load the iframe using
_getLinkerUrl
to link the visit inside the iframe with the visit on the top frame
- Use P3P headers on the iframed page to work around stupid internet explorer.
Additional Notes:
- Even if you don't care about the top level page you should add a tag into it, if you don't you can't use
_getLinkerUrl
and you lose the traffic source, etc. If you don't use _getLinkerUrl
GA inside the iframe will think it's a brand new visit referral from the top level page.
- Setting cookies inside an iframe, in a third-party domain is the definition of a third-party cookie. Because of that any browser that is set to block third-party cookies will block the GA cookies and GA won't work. This include Safari (both Desktop and Mobile) that are set to block third-party cookies by default. So if visits using Safari or iDevices are important for you (likely these days) this tracking won't probably give you good results. The only solution is to eliminate the iframed page, either put it in your domain or open it in a new window/tab.
Source: #11724605
Hope this helps!