1

How can i use event tracking feature in a iframe if the parent document uses the same Google Analytics ID but i don't want to double the pageview number? Can I disable the default page tracking or switch to "manual tracking"?

The story in brief: The parent document displays the comments in a iframe and i want to track some clicks inside the comment frame. I don't want to use different GA account to parent and child and also I don't want to merge the iframe into the parent document. I hope you can help me, I'll give you a FREE virtual BEER if you want some.

onetdev
  • 389
  • 2
  • 7
  • 17

1 Answers1

1

Iframe documents can detect that they are being iframed.

You can revert the logic and fire the GA tracking code only when outside of a frame:

if (window.self === window.top) { /* I'm NOT in a frame! */
// GA tracking code 
_gaq.push(['_trackPageview']) ;
}

Does this answer your question ?

Community
  • 1
  • 1
Open SEO
  • 1,682
  • 14
  • 16