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've followed Google's instructions on tracking iframed content on another domain (http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html#trackingIFrames) as best I can, yet there is still no data showing up in Analytics for the iframed page.

Parent page (http://www.blackangus.com/primeclub/):

<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-xxxxxxx-xx']);
    _gaq.push(['_setDomainName', 'blackangus.com']);
    _gaq.push(['_setAllowLinker', true]); 
    _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);
    })();


    var iframeLink = "http://www.fishbowl.com/clt/blckangus/lp/join/joinform.asp";
    jQuery(function() {
        _gaq.push(function() {
            var pageTracker = _gat._getTrackerByName();
            iframeLink = pageTracker._getLinkerUrl(iframeLink);
            jQuery("#joinform").attr("src", iframeLink);
        });
    });
</script>

And the iframed page(http://www.fishbowl.com/clt/blckangus/lp/join/joinform.asp):

<script type="text/javascript">
    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-xxxxxx-xx']); 
    _gaq.push(['_setDomainName', 'blackangus.com']); 
    _gaq.push(['_setAllowHash', 'false']); 
    _gaq.push(['_setAllowLinker', true]); 
    _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); 
    })(); 
</script> 

What am I doing wrong? Why won't the iframed page show up in Analytics?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Interessting. Your scripts seems to do three things:

  1. Add the GA snippet to the non-iframe page and execute the pagetracker
  2. Add some fishy looking code insertion on gaq.push
  3. Add the GA snippet to the iframe page and execute the pagetracker

Essentially what you need for the non-iframe is this:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XYZXYZ-XY']);
_gaq.push(['_setDomainName', 'blackangus.com']);
_gaq.push(['_setAllowHash', 'false']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();

and the exact same to your iframe-page (since it's not located at blackangus.com):

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XYZXYZ-XY']);
_gaq.push(['_setDomainName', 'blackangus.com']);
_gaq.push(['_setAllowHash', 'false']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();

But, this will count as two pageviews in your GA setup, since the iframe will also trigger a pageview. You need to setup a filter, which filters out the double pageviews.

And yes, you need to wait a couple of hours until the first results are displayed. Usually around 24 hours.

share|improve this answer
1  
Thanks, that's essentially what I've done. I found out that the third party implementing the GA tracking script on their end did not implement it properly, which resulted in a javascript and the page not being tracked. –  chrisofspades Aug 18 '11 at 6:01

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.