1

I'm working on adding Google Analytics via Google Tag Manager. I'm adding the tracking code to an existing tag programmed using Iframes in almost every page of the site.

There are multiple frameworks under different subdomains. Sometimes there are two frameworks serving data for one page, both using Iframes.

Is there a way to track the page view of the parent window without incrementing the page count when it is inside an Iframe of the inner one? In that case I would just want event tracking?

migrated from stackoverflow.com Sep 22 '14 at 10:12

This question came from our site for professional and enthusiast programmers.

  • You would either have to write some javascript on the innerframe not to run the "trackpageview" if your conditions are met, or better use something like querystrings on the iframes when the tracking is required and then use something like php, asp, to run the iframes. – Frank Sep 22 '14 at 12:35
  • Why wouldn't you just put the Analytics JavaScript snippet directly into the top level page? – Stephen Ostermiller Dec 2 '14 at 21:10
1

You would need to add a javascript condition to see if the page is a parent page or a child page and only add the GA code if the page is a parent page. If the sub pages you are talking about are only accessed through the frames and never on their own then you just add the GA code to the parent page and not to the framed pages.

Your Answer

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