Reputation: 4169
Please let me know if this should go on serverfault.. I'd like to know if it is possible to get a visitor referral, to know where he/she comes from from within an iFrame. The trouble I have is if someone say clicks a link on twitter (or any other site) that goes to a given page - the referral Google Analytics captures within the iframe is that of the parent window and not the referral itself.
what's the trick ? Thanks !
Upvotes: 0
Views: 1158
Reputation: 76656
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:
_getLinkerUrl
to link the visit inside the iframe with the visit on the top frameAdditional Notes:
_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.Source: #11724605
Hope this helps!
Upvotes: 1