Home » Featured » Using Google Analytics on Facebook Fan Pages

Using Google Analytics on Facebook Fan Pages

Can you use Google Analytics on Facebook fan pages and fan page walls? You betcher sweet ass you can.

If you’ve ever created a Facebook fan page, you’ve probably realized that the “reporting” that Facebook provides is basically useless. Because Facebook limits the Javascript you can use on Fan Pages, you cannot implement your own analytics packages on fan pages. Or at least, that’s what they want you to believe.

For Facebook applications, there is an FBML tag that will allow you place your Google Analytics code on the canvas page – but this FBML will not work on fan pages, application tabs, or anywhere other than the canvas page.

Fortunately, implementing Google Analytics on your Facebook fan page is possible, with a little PHP trickery. The basic gist of the workaround is to include your Google Analytics code as an image instead of placing the javascript into the FBML code.

Rather than writing something from scratch, it makes more sense to direct you to a post on the Webdigi blog that offers a free set of PHP scripts that will let you do exactly that.

The long and short of what the guys over at Webdigi are doing with their scripts is simply to call a PHP script instead of an actual image file in the <img src> code. This is not unlike the “tracking pixels” that are often used in email newsletters, since Javascript is not an option there either. So the concept isn’t new, but it’s not common knowledge that it works on Facebook.

The PHP script they are calling contains the Google Analytics code, and accepts parameters so that you can re-use the script on multiple fan pages (or different pages in an application) simply by setting different parameters.

When your Static FBML tab, application tab or non-canvas app page loads, it loads that “image” as part of the page. That “image” then pings the PHP script, which pings Google Analytics. This could be adapted for other reporting systems as well, using the same concepts.

The guys do a nice job with their script, and they even offer a wizard that helps you figure out what you need to put where.

I had rigged up a script a few months ago, but I never really had the time to package it for the general public, make it easy to configure, and so on, so go ahead and check out their script package.

Using this method, you’ll even be able to set up funnels and goals for your Facebook fan page stats, and Webdigi offers a great breakdown on how to tell the difference between fan and non-fan activity on your fan pages in your reporting.

Enjoy!

Advertisement

468x60_makemoney

Advertisement

Graphic River

flattr this!

About snipe

I’m a tech geek/dev/infosec-nerd/scuba diver/blacksmith/sword-fighter/crime fighter/ENTP/warcrafter/activist, and the former CTO and CSO at a business innovation agency in New York City. Tweet at me @snipeyhead or read more...
  • http://bryonsheffield.com/ Ironshef

    Yeah, this is pretty clever shit. Thanks for turning me onto the dudes over at Webdigi. Good stuff.

  • atlantajones

    Have you actually gotten this to work and track pageviews? I've tried everything, even using the hosted IMG code from their wizard, and GA still says tracking is not installed.

  • http://www.facebook.com/profile.php?id=40511955 facebook-40511955

    Ran into the similar issue atlantajones ran into. They provide the code though for personal hosting, so I may give that a whirl to see if that solves it.

  • http://www.facebook.com/Jewelove Sambhav

    I heard facebook is removing applications' profile boxes, is that true? Is it really happening?

  • atlantajones

    Following up, the tracking is indeed working. For some reason Google still says “tracking not installed”. Maybe that only means that the regular javascript-based tracking is not installed. Must not work the same for the tracking pixel technique.

    So yes, I can confirm this actually does work. What's cool is that our apps have multiple “views” within the same tab, based on date, time and/or other factors. And we can alter the tracking data to make them appear as separate URL's in analytics.

  • http://www.snipe.net snipe
  • Pingback: Facebook Versus the Internet | The Get Smart Blog

  • http://www.snipe.net snipe

    Hey Andrew – sorry I didn't reply to this. Past month has been hell. Glad you got it all sorted though.

  • http://www.snipe.net snipe