Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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', 'maindomain.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.

share|improve this question

2 Answers 2

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.

share|improve this answer
    
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 '12 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. –  toomanyairmiles May 26 '12 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 '12 at 17:50
    
@Shaun yes, that's the case. –  toomanyairmiles Jun 8 '12 at 17:57

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.

share|improve this answer
    
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 '12 at 0:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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