8

I have a site that contains the following characteristics:

  • Header is defined by code my team controls on subdomain B and is loaded via iframe
  • Body is defined by third-party code and platform on subdomain A and is the parent page
  • Footer is defined by code my team controls on subdomain B and is loaded via iframe

I am using Google Analytics (GA) to track pageviews. I would like the load of each page (consisting of all three elements) to register in GA as one pageview. In addition, clicks in the header and footer should not count as referred visits. How can I accomplish this?

I know that I can solve the referrer issue with cross-domain tracking:

['_setDomainName', 'example.com']

However, I also have to track the pageview to make it take effect:

['_trackPageview']

This would result in 3 pageviews tracked for one actual page load as far as the user is concerned. Since this particular site nets millions of visitors a month, tripling that is not ideal and would put us over the 10 million events Google Analytics will track reliably on the free plan.

2 Answers 2

1

I'd honestly have to question the complexity of the setup you're proposing, it won't help the usability of the site overall and you'd be downloading the script three times for no good reason. Include files were developed for precisely this reason and would strongly advise you to reconsider your plan.

Secondly you're bumping into the dividing line between GA and paid for solutions like webtrends or omniture which offer more scriptable tags. For a site of this size you really need to move into the paid for analytics field to help you make sense of this complexity. However this answer over at SO 'IFrame Subdomain tracking with Google Analytics' may offer a solution.

Otherwise I think you might be able to push some custom events for each tag which would allow you to manually add up the numbers and get a result, but GA simply wasn't built to cope with scenarios like this.

4
  • Believe me, I'm not a fan of the complexity of the setup. The problem is that we have an external vendor that controls the non-iframe content and we control the iframe content (menu) in an effort to make it consistent with the rest of our web presence since the items change occasionally. Changes in the product supported by the vendor are slow enough that our website would look broken if we couldn't update that portion. I also acknowledge we're a very exceptional use-case, hence why I'm punting to crowd-sourced expertise. :)
    – Shaun
    May 26, 2012 at 0:12
  • @Shaun fair enough, Have you tried pushing an event rather than a pageview? I think if you push the same named event in a single load google only records a single view - it's been a long time since i've done anything like this but it might be worth testing. May 26, 2012 at 0:21
  • Just to clarify: You suggest that, for the header, we use _setDomainName, then _trackEvent instead of _trackPageview to get Google to recognize the new domain for the header without double-tapping the pageview?
    – Shaun
    Jun 8, 2012 at 17:50
  • @Shaun yes, that's the case. Jun 8, 2012 at 17:57
0

I'm not sure this is possible with the current version of Google Analytics and is perhaps a suggestion you need to make to them.

However, if you're happy for only the main page (that includes the iFrame code) to be tracked, you could put the Google Analytics code on that page and not on your subdomain pages. This would mean any clicks inside the iframes would not be tracked which is probably not what you want. This would probably be better than your current situation though.

1
  • This is actually what we currently have. The main problem with this approach is that, when you click in the iframe to load something on or domain, Google Analytics thinks the iframe content was an external referrer. Conceptually, it's all the same site, though, so we don't want such clicks counting as referred visits.
    – Shaun
    May 26, 2012 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.