Google Analytics for Facebook Fan Pages

We launched our Facebook fan page earlier this month and as with all Facebook pages only Facebook Insights program is available to page administrators. Facebook Insights shows demographic details and interactions on your pages BUT limited to show information of fans only. It is far less sophisticated and comprehensive when compared to the free Google Analytics. One of the limitations of Facebook Fan pages is that you can only run limited Javascript on it and Google Analytics needs Javascript code included to correctly track visitors. We have successfully managed to get ALL functions of Google Analytics working on our Facebook fan page (including visitor statistics, traffic sources, visitor country, keyword searches with all other powerful reporting & maps overlays etc).

Google Analytics Example

How to setup Google Analytics on your Facebook fan pages

The workaround we use in our code is to include Google Analytics as an image instead of setting the standard Javascript. This method tracks every visitor to the custom facebook pages on Google Analytics. It required a combination of server side cookie management and an additional <img> tag to the bottom of the facebook fan page. Here are the steps to get Google Analytics working on your facebook fan page.

1) Setup Google Analytics account. If you already have one, create a new website profile. You can name it facebook.com or facebook.com/your_page_name. You will finally get your tracking code which looks like this UA-3123123-2
2) Create your custom img tag for each of your pages you like to track. EG: contact form, services, products etc. You can use our tool to create the Google Analytics link generator for Facebook pages.
3) Add the entire custom image html tag from step 2 to the bottom of each Facebook fan page that you need to track.

That is all there is to it! Google Analytics is not real-time, so you will need to give it some time. Approximately a day before you see the fruits of your “hard” work.

For advanced users

Use this method, if you don’t want to use our hosted link redirection as mentioned in the method above. You can download the entire source code which is just about three files to get this setup working on your own server (running PHP4.3 or above). The code is written in PHP and essentially creates the Google image tracking URL with the referrer, page information, ID, etc. The additional advantage of hosting this on your own server and domain is that visits from your website to your facebook fan page gets tracked, etc. You will also be able to customise further if you wish. Please do share any useful updates you apply to the tracking link code.

Facebook – Google Analytics Tracker v1.1 (Updated 21st Feb, 2010).  For advanced method – Download this code to use on your server.

If you don’t have a Facebook fan page yet, visit our tutorial for code and help on creating customised Facebook fan pages.

PS: We could not find any other source / blog that described how to get Google Analytics on Facebook fan pages! There is support for canvas pages and applications but nothing for StaticFBML fan pages. Hope this helps and please leave your comments below.

UPDATE:
1) A lot of users have asked how to track visits to the wall. Yes, this can be done. Please see the comments by iphp below.
2) Here is a screenshot to a staticFBML where the code should be placed
3) We have managed to set up funnels, goals and segments to separate fan and non fan activity.
4) Video: Here is a link to the Webdigi youtube channel check our favourites to get step by step walkthrough!
5) This blog and comments cover all aspects of setting up Google Analytics. If you still want help, we are available to offer paid support and installation of Analytics for your page. Please contact us here.

Also read...

Comments

  1. David said on :

    Thanks for sharing. I have been waiting for a proper replacement to Facebook insights for ages.

  2. Hosea said on :

    Simply Amazing! I am sure that adding an image tag is simple and allowed by all sites. So this workaround should help with all similar sites that do not allow javascript too. Not only facebook fan pages!

  3. Matthew Forr said on :

    Well done, I’ll have to give this a try.

  4. Oliver said on :

    Awesome, just downloaded and setup on the server and it looks ok so far. Waiting for google analytics to update.

  5. Grace said on :

    Sounds great. @Oliver How did you setup on your server? Any particular advantages of hosting it by yourself?

  6. Pingback: Google Analytics for Fan Pages? :: Moko Marketing :: Facebook Marketing Agency

  7. Pingback: Christians dagbok – 2010-02-22 | En sur karamell

  8. Pingback: » Google Analytics for Facebook Fan Pages – PHP, Web and IT stuff - gltss.org

  9. Pingback: Usare Google Analytics con le Fan Pages di Facebook | maxzaglio.com

  10. Patrick said on :

    Hi Guys,

    Nice work here. A few questions though. On Facebook images called up from within a Fanpage Tab view are cached by Facebook. So without some sort of cache breaker (a time on the image src url will do it) your image is only going to be called the first time. No big problem there.

    The real problem is that it’s not technically the end user who is loading your image. So you’re not getting any real data about that user including their browser settings etc. Nor could you do any type of cookie management during the image load.

    It doesn’t look like this solves the latter problem. I’ve been through the code and don’t see anything that would seem to take care of it. Am I missing something? Am I making bad assumptions?

  11. Pingback: » Google Analytics for Facebook Fan Pages – PHP, Web and IT stuff

  12. iphp - Author said on :

    @Grace, @Oliver If you use the advanced option of hosting the code by yourself, you will be able to track visits from your website to your fan page and back. Also preserving the original referrer to your website, etc. It might also be better than relying on our servers.

    @Patrick Also, to clarify, the images generated from the server is loaded by the actual user and not Facebook. Also static FBML cannot be changed for time, etc easily as Javascript onload is blocked

    On our Google Analytics we are able to see which device was used (Iphone, Android, Firefox, etc). We are able to see the location, track usage with cookies, time on pages, track visits after some time, etc. This complements Facebook Insights well. Also note that the page created using StaticFBML is static and the URL cannot be changed all the time. Let me know if you have any ideas and please do share code improvements that you make.

  13. Pingback: Flow » Blog Archive » Daily Digest for February 23rd - The zeitgeist daily

  14. Adido said on :

    Wow! This is excellent stuff! Thanks for sharing!

  15. Nikki Rae said on :

    This sounds great. Well done. Got a client or two in mind already!
    Thanks
    Nikki Rae

  16. Pingback: John

  17. Jim said on :

    I bookmarked this blog. Thanks heaps for this!

  18. Pingback: Google Analytics for Facebook Pages

  19. Marta said on :

    Very interesting, Thanks for the information!!

  20. Car said on :

    Probably an elementary question, but “Add the entire custom image html tag from step 2 to the bottom of each Facebook fan page” — where exactly do I put the html tag? Thank you!

  21. Omar said on :

    Great article, but I am not sure I understand where I am supposed to place the code. For example, lets say I want to track the wall on my fan page…where would I place this code? There is no way to access the HTML of your wall on facebook…

  22. Phoenix2life said on :

    Awesome post. Thanks for sharing these knowledge bits.

    Some newbie questions. I have completed two steps. First created google analytics account for Facebook Fan page and received google analytics code. Second generated Image from the UI you have shared. After that I have added FBML box to my facebook fan page and have copied the image code generated. When I have checked status from Google Analytics, I am getting tracking code is not installed message. Would you please help me on this ?

  23. iphp said on :

    @Car, @Omar Please read the our previous article on creating custom Facebook pages. You can then put your codes there.

    @Phoenix2life, Thanks! All you need is patience now. It sounds like you have done everything correctly. Google Analytics is not real time as mentioned in the post. If you come back tomorrow you should see your graphs work and you will also see “not installed” message disappear.

    For those who want to test out Google Analytics, please put a link to your fanpage here you might get more visits to show up on Analytics. But please note, you have to wait for Google in any case.

  24. Pingback: The Ultimate Facebook Page Resource Page

  25. Pingback: News Alert » Blog Archive » » Google Analytics for Facebook Fan Pages – PHP, Web and IT stuff

  26. Láďa Durchánek said on :

    This is awesome, maybe it will work even for profile pages if you use it in some Static FBML box. But another important question – Facebook does not cache this image?

  27. Pingback: Google Analytics per le pagine Fan su Facebook

  28. Bill said on :

    Thanks, articles like this help me remember to work on FB, which I tend to ignore as just an add in. Thanks,

  29. Pingback: Le migliori applicazioni per Facebook Fan Page | My Social Web

  30. Jim Goldstein said on :

    Thanks for this great info. Very helpful!

  31. uigher said on :

    Does this work on forums (in signatures for specific pages) and other SNS like myspace etc. I tried in in myspace but it didn’t work but maybe I botched something.

  32. Pingback: » Google Analytics for Facebook Fan Pages – PHP, Web and IT stuff | Drakz Free Online Service

  33. Jay Baer said on :

    Thanks so much for putting this out there. Hugely helpful. You made my day. I just tweeted it up big-time.

    Cheers,
    j

  34. Pingback: 2/24/2010 Update « Go Code

  35. Bill Kilner said on :

    What an interesting method. Thanks for this, I really appreciate what you have done here. Keep it up, and I will be back for more. Bill Kilner

  36. Mary said on :

    This is a really valuable info. Keep up the good work. Mary Jo

  37. iphp said on :

    @Jay Baer, Thanks for sharing!

    @Durchánek, Facebook fan pages request end browsers to display the image directly and are not cached by Facebook.

    @Uigher, Theoretically, you should be able to use this anywhere. Facebook, myspace, etc if they allow you to place img tag and if the actual user browser is loading the image.

  38. Andy Adido said on :

    Had a play with it now. I’ve done everything that you’ve highlighted but am I right in thinking that due to having to use FBML you can only track the pages that you build yourself? How do you view who looks you at your wall/3rd party boxes which are put onto your FB page?

    Please let me know if I’ve missed something!

  39. Pingback: Pi Blog» Blog Archive » Facebook Fan Pages Get Google Analytics

  40. Pingback: Analytics sulle fan page di Facebook? no. si. dipende • Google Analytics in 30 secondi

  41. rudi said on :

    @ iphp is it also possible to make a distinction between males & females in the google analytics for Facebook?

  42. php-manual said on :

    @rudi, yes this is why you would use facebook insights along with Google analytics. You can have the best of both worlds.

  43. Shailendra Dubey said on :

    The post is very interesting, i would like to implement it.

  44. Alex Becker said on :

    Excellent post. I was speaking on a panel last night about Google Analytics and a question came up about this exact topic…really great post here. Retweeted @aybecker

  45. New Orleans Web Design said on :

    Where, exactly, do you paste the image code? Did the recent Facebook redesign change this procedure?

  46. MLO said on :

    Does anyone know where you paste your google analytics code on facebook? Where do you do this? What part of the page can this code be posted to?

    Thanks for the help!

  47. Mike Plummer said on :

    As the article points out, make sure you select create a new profile for a new website / domain in Google Analytics. If you don’t create a new profile code or exclude this data with filters from your existing profiles, the facebook GA data will come along with all your visitor / session / traffic sources data in your existing profiles… technical reason is cookies won’t align

  48. Pingback: How to Use Google Analytics on Your Facebook Fan Page | Search Engine Journal

  49. Manoj said on :

    Can this work with Facebook Groups?

  50. chris faron said on :

    Great idea was looking for a way to track non javascript browsers like some smart phones, if I use it on the same domain can i just create a new profile/existing domain?

  51. Justin Kistner said on :

    Patrick is right. While the redirected image is loaded by the browser, the first call is as an image and that is the part that is cached by Facebook. We checked on the activity on your Facebook fan page using Fiddler and after the first couple of page loads, the server calls stop, which is the cache kicking in.

    I work at Webtrends and we’ve been addressing the same issues. We threw out the cache breaking approach as well after it failed in testing. Full disclosure, tomorrow we’re announcing our solution for tracking tabs.

  52. GSEO said on :

    It is certainly amazing that this is now possible!

  53. Pingback: ¿Cómo poner Google Analytics en tu página de fans en Facebook? | Jorje Rojas

  54. Jake said on :

    Excuse my ignorance, but new to this and trying to get set up for my emplyer business page – how do I “Add the entire custom image html tag from step 2 to the bottom of each Facebook fan page that you need to track”?? Thanks

  55. Adam Smith said on :

    Nice job i have tried it for my blog fan pages, it work really easy.

  56. Sandra said on :

    Thanks for this great information – will try to install immediately.

  57. iphp said on :

    @Jake, @MLO
    You can definitely track visits on your Facebook page Wall as well. You will have to create a new static FBML box and place the img tag html code in it. To see this in action, Go to our fan page wall, you will see a box on the lower left called Articles which has a Google Analytics tracking code.

    After you create your new StaticFBML, go back to edit your fan page. Under Application Settings for the entry you created, you can remove tab and add a box. Once a box is added it will be displayed under the Boxes section. All you have to do is to click on the little edit icon and select “Move to Wall”.

    Doing the above will place your tracking code into the wall page and you will be able to track users on your fan page wall! Its easier than I made it look. Give it a go!

  58. Astrid said on :

    Genious! I didn’t know what a static FBML page was until now *blush*, but it is so simple! Thanks a bunch guys!

  59. Cecelia said on :

    Haven’t worked much with Facebook fan pages (and even less with FBML) but I’ll have to give this a try. Thanks!

  60. Pingback: The Missing Google Analytics Manual

  61. Paul said on :

    Hey, I’m having problems understand this: “3) Add the entire custom image html tag from step 2 to the bottom of each Facebook fan page that you need to track.”

    Where and How do I have to paste the generated code?

  62. Andrea said on :

    Any additional help on installing the files on our own server? Tried it and it generates code, however the image is broken?

    Thanks!

  63. Andrew said on :

    Thanks for this awesome tip! I must admit, I’m stumped as to why it isn’t working for us. I set up a new profile in Google Analytics, created the box and published it on our wall with the img tag from your generator. What could I be missing?

    facebook.com/Vmeals

  64. Jeff Woodruff said on :

    Great article. I have wanted to add analytics to a few fan pages I administer for some time but didn’t know it was possible. Thanks!

  65. Eduardo said on :

    Got it up and running on the wall of a facebook fan page. I assume that since the tracking is done indirectly, the “status” on google.com/analytics/settings/home should show “tracking installed”, correct iphp?

  66. Jake said on :

    @iphp cheers, many thanks. great blog

  67. Meredith said on :

    Hi there. We are very excited to see this. We added Analytics to our page however after 14 hours we haven’t seen anything show in the Analytics. We think there may be some issue over the page name – for instance, you listed “Contact_Page”, however each of our static FBML pages have a much longer string attached. ie, our Landing Page’s string after the facebook.com is /videosocialmarketing?v=app_4949752878&ref=ts. Is this the string we add to your form? Thanks so much

  68. Mehdi said on :

    Thanks for this helpful post.

    I’ve integrated the tracking code within 2 tabs and the wall, it’s working fine.

    But…the tracking code doesn’t seem to load every time we click on a tab. WASP is confirming this assumption. I’m on the Services tab then I click on the Contact tab but WASP keeps capturing the Services tab as a pageview.

    Can you tell me if I’m right?

  69. Pingback: How to Set Up Google Analytics for Facebook Pages | TechPetals

  70. Mehdi said on :

    Actually, the tracking code placed on the Wall tab is always loaded, even if we are on the Service tab.

Comments are closed.