1

I build pages on my clients website that can be iframe on their partners websites.
I included this GA code on the website.

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-1494300-1']);
    _gaq.push(['_setDomainName', 'mysite.com']);
    _gaq.push(['_trackPageview']);

    (function () {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        _gaq.push(['_trackEvent', 'iframe', '/products/default.aspx', 'Petersburg- Zip Code:26847',, false]);

    })();

I've verified that the code shows and is being called when the site is pulled in from and iframe, However, we are not getting any event data in GA. I've read up on iframes and GA tracking and most of the issues seem to be the result of cross domain limitation. However, with this implementation i do not need any info from the parent and the parent doesnt need any info from me I just need the event data. Any ideas?

SirM
  • 487
  • 6
  • 22

2 Answers2

1

Google Analytics depends on cookies. Cookies inside an iframe in a different domain are technically speaking 3rd party cookies. 3rd party cookies will be blocked by Safari by default. You should still see most traffic for Chrome and Firefox users, except for the minority of users that change the default settings.

For internet explorer traffic you must make sure you implement a P3P Compact Policy in the Response of your iframe. Otherwise 3rd party cookies will be blocked as well.

Read more about how to set P3P CP headers for Google Analytics.

Community
  • 1
  • 1
Eduardo
  • 22,574
  • 11
  • 76
  • 94
  • This started working on its own, usually these is up to a 24 hour delay for GA data to show, but for some reason it was longer than that when I posted I also added the P3P header as well for IE. – SirM Feb 13 '13 at 13:59
  • I've been testing this and I see Safari data but I don't see data from Internet Explorer. IE (at least version 8) seems to need a P3P header or more to work around. – Muskie Jun 14 '13 at 17:26
1
  1. Make sure you don't have any filters filtering out the data
  2. Make sure the domain listed in your _setDomainName matches your iframe's domain
  3. Make sure you are pointing to the right account #
CrayonViolent
  • 32,111
  • 5
  • 56
  • 79