Google Analytics for Facebook Apps

Hi - you seem to be new here. Please subscribe to my RSS feed to get the latest social news and information!

Please follow me on Twitter, Facebook, or FriendFeed to see what I'm up to. Thanks for visiting!

Today, Facebook announced they were releasing a new FBML tag for developers that would allow developers of Facebook Apps to track their applications via Google Analytics. Before this, because the code you put on your page is javascript, there was no way to track your apps. I tried to install this, but ran into issues, in that Google tries to look at your main facebook app page for the javascript (which isn’t parsed by Facebook), while Facebook gives an error if you put the raw Javascript on the page. I came up with the below solution, which works like a beauty - you put your javascript between your <fb:google-analytics> tags, like this:


<fb:google-analytics uacct="12345">

<script type="text/javascript">

...

</script>

</fb:google-analytics>

Since Google reads the plain callback url it won’t interpret the fb:google-analytics, and Facebook ignores everything between the <fb:google-analytics></fb:google-analytics> tags. Works like a charm on mine.

Similar Posts:

Join the Discussion on FriendFeed:

7 Responses to “Google Analytics for Facebook Apps”

You can subscribe to the RSS feed for comments on this post. You can also reply to this post directly in your weblog, and take advantage of the TrackBack URI to record your reply in this post.

  1. Ankur says:

    Hmm.. interesting observation. I wonder if you can add adsense code this way

  2. Adam says:

    What URL did you give to google? For example, I gave apps.google.com/liarliar as the URL.

  3. Adam says:

    Typo — that should have been apps.facebook.com/liarliar

  4. uncle_jesse says:

    You can’t add your facebook url - it has to be the url your facebook canvas page is pointing to. My url is http://grandcentral.jessestay.com - my facebook callback page points to that, and that’s what gets loaded in the iframe. Google can also read that, as there is no authentication required, so I just put the above code in my footer for that page.

  5. Adam says:

    Ah ok thanks.

  6. uncle_jesse says:

    I don’t think adsense code would work that way - it may be readable outside Google, but facebook completely ignores what’s between those tags. Facebook needs to render the javascript for you, or it will generate an error.

    One way you could get around it possibly is if you could figure out a way to read the output of the javascript for the ads, and convert it to flash. Flash/SWF works just fine in Facebook (with some limits on the profile pages).

  7. Chris Nolan.ca says:

    What I did, was just make a new index.html, put the code it it, hit the page, let google return the hit — that ‘activated’ me. Now I’ve gone back to normal.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Close
E-mail It
Blog Directory - Blogged