iframes loading content from the same domainLets use an iframe to load Daniel's biography on this page:
We're loading content from online-behavior.com on this page which is also on online-behavior.com. This seems pretty trivial but actually, it's making Daniel's GA data do some unexpected things.
What happens to Online Behavior's GA data?When Daniel checks his GA data he'll see two pageviews. Unfortunately he'll see very low values for the time on page and bounce rate metrics for this page... As this page loads and sends a pageview hit to GA, the very next thing that happens is that the browser displays the iframe. The iframe loads Daniel's bio page, which in turn sends a pageview hit to GA too. As far as GA is concerned, this looks like you clicked on this article and then very quickly clicked through to Daniel's bio. GA doesn't know that the bio is loaded in an iframe. This means the time on page for this page is crazy low and it's also pretty impossible to bounce from this page as we're forcing two pageviews to fire in a very small space of time. This is not great as the data isn't a true reflection of user behaviour. You may have spent a few minutes reading this far (thanks!) but GA doesn't show this - it shows a time on page of 1 second or less.
What's the fix?Typical Analyst answer - it depends. In this instance, it depends what Daniel wants to have happen to his data. You need to decide what's right for your data. Let's explore some options. You could take page tracking off the iframe. The metrics for this page will be restored but what about the tracking on Daniel's biography? What if this wasn't a trivial example and the iframe contained a form? How's that going to be tracked? You could filter the iframe pages into a view for conversion tracking but make sure you know whence the user came when attributing conversions to channels. The solution to preserve your data quickly gets very complex as is normal with an 'it depends' type answer.
The actual fix is to not do this in the first place. Your data is compromised as soon as you decide to compromise the page implementation using a iframe.If you have key content, like a form, that you want on the page, build it properly and track it properly. If it's key to your business, making the effort to build your pages right is a sound investment that will deliver a return.
iframes loading content from a SubdomainLoading the content in the iframe from a subdomain is just as bad as loading the content from the same domain. It's a compromise. Don't do it.
iframes loading content from a 3rd party domainYou've probably seen this scenario a lot. Think about sites where you've seen links to news stories with "Recommended by Outbrain" or "Sponsored content by Taboola" on news pages. It's a common content syndication solution. Most sites showing adverts will display the ad in an iframe. The ad is chosen by another system and displayed from a 3rd party ad server. These use cases are good examples of where iframe behaviour is desirable. Browser security settings (The Same Origin policy) prevent 3rd party iframe content from interacting with the outer page. This is a good thing for the safety of users. Whilst this case is well understood and a correct use of the technology, this is actually where you need to be properly terrified. Okay, that's a little strong but you do need to scrutinise the iframe behaviour very carefully.
Content syndicationSo you've displayed
3rd Party Ad ServingOkay, say your site is a publishing site rendering an ad. Maybe the ad click is heading off to another 3rd party. The advertising tech probably handles the ad serving and click measurement. No worries. However, there are two scenarios worth considering.
1. The ad click takes users to your siteDoubleClick ads are rendered in iframes. If you're rendering "internal" banners to drive promotions on your site (sometimes called House Ads), the ad clicks will end up on your site. Fine, you're using something smart like DoubleClick for Publishers (DFP) so your measurement (assuming you've setup the tool correctly) will be unaffected (read more about the GA360+DFP integration). Check your data if you use alternative marketing software to render your house ads. Make sure your precious channel data is not polluted by referrals from the iframe 3rd party domain.
2. The iframe loads resources from your siteWhat if you're rendering rich media ads and/or there is some communication between advertiser and publisher content? You might use the DoubleClick Rich Media iframe approach. If these instructions aren't followed and
DARTiframe.htmldoesn't exist or can't be found then you'll end up with a third party requesting content from your domain on the user's behalf resulting in a 404 error and session data breakage. You'll know you're in trouble when you see a step change drop in your session duration and an increase in referrals from
tcp.googlesyndication.com. You may also see the inflation in requests for
tcp.googlesyndication.comas the referrer) if you're tracking 404 errors. There is a wealth of documentation out in the wild on the internet that might suggest your ad autotagging is incorrect. This will lead you down a false path. Look for
DARTIframe.htmlrequests to confirm ad autotagging is not the issue.
Used properly, iframes are excellent tools to render 3rd party content safely. Used badly, the user experience suffers, your data becomes meaningless and your site becomes a rat nest of hacks and make-do compromises.Choose your markup carefully and be aware of what the possible effects are on your data. In a fast moving, complex organisation you may not have 100% control over all pages and all campaign implementations. Maintain visibility of your data and prepare to act if you see symptoms of pollution, reduced data quality and unexpected step changes in key metrics.