Facebook and the new Google Analytics ga.js tracking
You’ve got to question the decision by the Google Analytics team to recommend the use of document.write in the updated version of their tracking script. Aside from breaking any XHTML pages served correctly, it also doesn’t work in IFRAMEd Facebook applications—I guess they don’t like document.write either, most likely for security reasons.
The solution, of course, is to simply include the script tag as normal:
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>
I don’t think you can serve HTTPS pages within the Facebook iframe (unless you re-frame within your own pages, maybe?) so the protocol won’t cause a problem.
Filed under: Javascript.
Technorati tags: facebook javascript google analytics
Bookmark this article with del.icio.us
Previously: Mac Gaming: Battlefield 2142 on Mac OS X
Next: Selflessness
Comments
- Matthew Pennell
- 1539 days ago
I think I’ve just put the iframe src domain – we only launched it yesterday though, so I haven’t been able to verify whether it is collecting any data yet… :D
- #2
- Andy
- 1539 days ago
Ahh.. When you do the ‘Verify’ link in GA, does it ever return successful?
- #3
- Andy
- 1539 days ago
Ahh.. When you do the ‘Check Status’ link in GA, does it ever return successful?
- #4
- Matthew Pennell
- 1539 days ago
It says it’s collecting data, but I can’t be sure whether that was from our internal testing setup or not.
Presumably if it is impossible you just have to rely on Facebook’s own tracking stats. More investigation needed, I guess!
- #5
What URL do you put in GA for the website URL? I’ve tried using just the call like you show here for the iframe canvas page of my application, but whenever I try and verify it in GA, it can’t find the code..
I’ve actually tried putting both the facebook URL (apps.facebook.com/myapplicationsname) as well as the call-back URL which is the SRC of the iframe.. but no dice.
Any ideas?