Categories
Facebook

Why Google Analytics Can’t Run in Facebook iFrame Apps

facebook google analyticsThere has been a lot of talk lately about Facebook iFrame apps and Google Analytics.

I’ve been asked several times from people about the possibility of running Google Analytics for the new iFrame tabs.

And so I’ve been searching for a way since last week to make this happen – to make Google Analytics run within a custom iFrame tab on a Facebook Fan Page.

The benefits would be great because you’d be able to see what kind of traffic your new app was getting.

However, my searching came to end yesterday when it occurred to me why Google Analytics, or GetClicky, or any other analytics tracking code for that, cannot run on an iFrame tab.

The reason is because iFrame tabs are iFrame’s.

Duh… really?

I realized yesterday that because these pages are an iFrame running within Facebook, the application that you build it not generating it’s own unique page views, only the page views from within Facebook.

So in the traditional form of pasting your Google Analytics code into an iFrame app, it’s not going work.

This doesn’t mean, however, that traffic analysis is not possible – because it is.

But the analytics integration has to come from within the code and frame of Facebook, not Google Analytics.

The bottom line – is it possible to analyze traffic to your iFrame apps?

Yes.

Will it happen by pasting Google Analytics, or any other analytics code, into your iFrame tab?

No.

Stay tuned as I continue down this road of generating analytics for iFrame tabs.

9 replies on “Why Google Analytics Can’t Run in Facebook iFrame Apps”

I just helped someone set up Google Analytics with the Static HTML app ). The comment thread is here:

I’ll copy-paste the instructions I wrote there for convenience. :)

– Jason

———–

You’ll want to use a Google Analytics snippet that is set up for “multiple domains.”

The good news is that for this particular instance, probably all you need to do is add two lines of code to the standard Google Analytics snippet and you’ll be fine. Or you can just copy-paste the snippet below, add your specific tracking id, and you’ll probably be fine. Let me know if it doesn’t work!

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try{var pageTracker = _gat._getTracker("UA-12345-1"); // Replace UA-12345-1 with your code
pageTracker._setDomainName("none"); // ** THIS LINE IS NEW!
pageTracker._setAllowLinker(true); // ** THIS LINE IS ALSO NEW!
pageTracker._trackPageview();
} catch(err) {}

This doesn’t make any sense to me. Why don’t you just install the Google JS into the base page you’re loading into the parent iFrame on Facebook? You could even have nested iFrames within your app and have different instances of Google Analytics running in each, so as to measure user interaction with different areas of your app. I’m not sure what you recent articles on the subject are really about other than misunderstanding the way nested frames relate to measurement.

Hi J. – your comment makes sense to me, except that I have yet to be able to
get data feedback via Analytics.

can you give me an example where within the code I would put the Analytics
code?

Hi Ed – I was able to find where there are Google Analytics fb tags, but I
haven’t yet figured out the code on implimentation.

You can add Google Analytics!
The only limitation is that you won’t get the referers since facebook will always be the referer.

Here is an article about how it works:

Leave a Reply

Your email address will not be published. Required fields are marked *