Google analytics and iframe content - will all tracking work?

I saw a bunch of posts here about tracking Google Analytics and iframes and how there might be some problems. Also seen this: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite#trackingIFrames

I have a tracking code on a parent website that I am not interested in, and I have a tracking code on a page that is embedded in an iframe that I care about. Iframe content is a completely different domain.

I was wondering if the iframe page would be able to get all the demographic information and correctly send data to Google to track events and something else. Again, I do not care about motherhood in general in this case. It’s just that the google analytics code in the iframe works completely by itself.

It seems to me that the article that came out of Google refers to users who want to somehow connect the analytics in the iframe with the analytics in the parent device, but could I be wrong?

+4
source share
1 answer

The documentation describes exactly what you need to do. It really comes down to:

  • Load the iframe with _getLinkerUrl to associate the visit inside the iframe with the visit to the top frame
  • Use the P3P headers on the iframed page to work with a dumb Internet Explorer.

I would add some notes:

  • Even if you do not need a top-level page, you must add a tag to it, if you do not, you cannot use _getLinkerUrl and you will lose the source of traffic, etc. If you do not use _getLinkerUrl GA inside an iframe, consider this a new referral visit from a top-level page.
  • Setting cookies inside an iframe in a third-party domain is the definition of a third-party cookie. Because of this, any browser that is configured to block third-party cookies will block GA cookies, and GA will not work. This includes Safari (both Desktop and Mobile), which by default block third-party cookies. Therefore, if visiting Safari or iDevices is important to you (probably these days), this tracking will probably not give you good results. The only solution is to exclude the iframed page, or place it in your domain, or open it in a new window / tab.
+3
source

All Articles