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. Raphael said on :

    I´ve installed the tracking code in my client page and it works perfectly!
    My doubt is in GA the information about “time on site” is 00:00:00 and you said that this info is working.
    Any issues with that?
    facebook/animalebrasil

    TKS!

  2. Johann de Boer said on :

    Does the advanced method (i.e. installing on our own web server) allow tracking of referral paths other than just referrals from our own website? I.e. can this method be used to track what other websites referred visitors to our Facebook page?

  3. Pingback: Tracking Hosted Wordpress Blogs With Google Analytics « Si Quando Dubium, Illic Est Scilicet

  4. Pingback: Designing A Facebook Fan Page: Showcases, Tutorials, Resources - Smashing Magazine

  5. Pingback: Designing A Facebook Fan Page: Showcases, Tutorials, Resources | Web Design Cool

  6. joanne Delbalso said on :

    Great Blog post!! I just did this and it was easy as pie!! thanks for the info.. I will pass this on !!

    Joanne DelBalso
    @nofussacctng

  7. Hubert said on :

    Hi, great job!
    Can I use fgba for tracking email marketing campaign?
    It’s seam that’s possible… it’s like the classic gif insert method

    Domain on Analytics: mydomain
    Page Link: alternate-webpage-url-of-email-HTML/newsletter-date.html
    Page Title: newsletter-date

    [don’t need GA-code in the alternate page, keep the img gif code]

    Thanks you very much, very usefull

    Regards
    @dmsr

  8. Stuart G. Hall said on :

    Thanks for sharing!

    Cheers,

    Stuart

  9. Chris said on :

    Thanks a lot for this I followed your directions and I am getting the “Tracking Not Installed” error code, I will give it some time and see if it starts working. Once again great blog post and thanks

    Chris
    @lifterCatcher

  10. Chris said on :

    Here is the link to my fan page to hope to get some clicks to see if this is working.

    facebook.com/pages/Our-Fitness-Journey/158321227279?v

  11. Nate said on :

    Update: after a couple more hours, the GA registered the feed. I’m anticipating my first daily report in an hour!

    Thanks again!

  12. Cat C. said on :

    Hi,
    I have tried this over and over and I guess I’m doing it wrong because I still can’t get the reports to start. Here is what I have been putting into the FBGAT code generator:
    Analytics Code: Check, I have that.
    Domain: facebook.com/wsuspokane
    Page Title: This is where it’s confusing. I don’t know whether to put “WSUSpokane” (the fan page name) or “Cougs” (the name of the box the code is in).
    Page Title: This is confusing as well, page or box?
    Any help would be appreciated, but it doesn’t look like you are answering comments anymore. 🙁
    Cat

  13. Laki Politis said on :

    @ iPHP, though it might seem logical that using fb:google-analytics on a canvas page would be applicable on a profile tab, too. Hopefully, I can save someone some headache, or maybe they could tell me what I’m doing wrong. But your tracking method worked, and I said no more need to beat my head against the wall.

  14. iphp said on :

    @Chris, @Stuart, @Nate, @Joanne, @Hubert.
    THANKS! Thank you for your comments. I hope this encourages people who are nearly there with integrating Facebook to

    @Cat C.
    Sorry for the delay in replying. We have been really busy. I hope you have already figured out the issue. Can you please post the link to your facebook page? Page Title does not matter, it is just to help you identify the page when you see the reports.

  15. Leigh Clements said on :

    What a great solution. I’d like to try it out, if anyone can give me a hand just by visiting the page so I can see if it tracks in a few hours. Thanks again!!

    facebook.com/shotinthedarkmysteries

    🙂
    Leigh Clements
    Shot In The Dark Mysteries

  16. Matt said on :

    Heads up, FB is killing boxes = no more GA for the Wall. Anything in the works from Webdigi?

  17. Bryan said on :

    Thank you for all of your help. I’ve been able to set up analytics on the Wall of my page and am tracking visits, but so far the Overlay function doesn’t seem to be working. Is there anything special that needs to be done to set it up?

    Thanks!

  18. Beate Lorenz said on :

    Thanks to your post successfully implemented Google Analytics to our fanpage’s wall. So far it has been working perfectly!

  19. Monique said on :

    Dear iphp,

    Thanks for the tutorial. It works everywhere except on my wall.
    I put the code in a FBML with some other info so that the box would show up.
    Under Application Settings I removed the tab and added a box.

    But the next step:
    “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”.”

    I dont know where i can find that. can you discibe this some more? Maybe add a screenshot?

    Thanks!

  20. Lisalicious said on :

    ah amazing! I didn’t know we can use Google Analytics for Facebook Fan page!

    Now I will try to use it!

  21. Isan said on :

    Thanks to your post successfully implemented Google Analytics to our fanpage’s wall. So far it has been working perfectly!

  22. Jenni said on :

    Great followed the tutorial step by step yesterday and it works perfectly on all pages & wall for me!! Thanks you guys are amazing!

  23. Maggie said on :

    Facebook is planning on removing boxes from profiles. I know the code will still work on the tabs but do you have a solution for tracking wall visits without boxes?

  24. Aimee said on :

    It all makes sense up to step 3. I don’t know how you just put an image at the bottom of a page on facebook, I have no control of the layout of facebook, or editing the html. I need a bit more explanation of that step please.

  25. Hector said on :

    A-W-E-S-O-M-E thanks for offering this to the open public.

    Question, can I somehow pass custom “user variables” to GA? Whether using the hosted version or tweaking the self-hosted?

    Thanks!

  26. iphp said on :

    @Leigh, @Beate, @Isan, @Jenni
    Thanks for taking your time to comment on your success. This will certainly encourage people who are getting started.

    @Aimee
    To put an image on the bottom of a page on Facebook, you need to setup Static FBML to be able to do this. This is how your staticFBML page will look like. webdigi.co.uk/blog/wp-content/uploads/2009/06/adding-img-tag.png

    @Hector, Absolutely, you can pas your custom user variables to GA. You have to tweak the self-hosted version. Please keep in mind that all you have to do is to generate the correct URL and things should work. Please let us know if you manage to get additional analytics information, we can probably add it back into the hosted version for the public.

  27. Hector said on :

    Thanks! Will definitely share it back if we get it working. Again, thanks for sharing this with everyone.

    🙂

  28. Pingback: Smashing Magazine: Designing A Facebook Fan Page: Showcases, Tutorials, Resources « Facebook applications for developers

  29. Pingback: 8 Things You May Not Know About Facebook «

  30. Pingback: 8 Things You May Not Know About Facebook - OCSEA

  31. Pingback: How to install Google Analytics on your Facebook Fan Page « MARKETING STRATEGIST

  32. Datis said on :

    @ipha –

    How are you able to track wall visits now that boxes have been disabled?

    Thank you very much.

  33. Miguel Gaxiola said on :

    Dear iphp, I’ve read all this blog and there is excelent information. Thanks, but I got an issue, when you posted before that to track the Wall you need to add a staticFBML to the wall changing the settings adding a box and remove tab is where the troubles comes up. When I go to settings only the TAB configuration to add or remove appear, nothing about to ADD BOX only to add or remove TAB. How can this be configured or changed?

    Thanks!

  34. Pingback: 8 Things You May Not Know About Facebook

  35. Craftyman said on :

    Screencast: How to Add Google Analytics to Your Facebook Fan Page

    craftyman.net/google-analytics-facebook/

  36. jacopo said on :

    Facebok got rid of the boxes!
    Is there a way to track the wall now?

    I don’t see any!

    Please deny me 😀

  37. Casey said on :

    Thanks for sharing this. I knew it was just a matter of time.

  38. mc said on :

    Is there a way to track fanpage Wall (as BOXes are no longer available)?

  39. Benjamin said on :

    Hello,

    This article is really interesting. Thanks for sharing this tips.

    But I still have a problem for tracking the wall activity.

    How do you do to put the code on the wall since Facebook remove the box?

    Have you fin a work around?

    Tx for answering.

    Have a nice Day,

    Ben.

  40. DerRudi said on :

    Hi, It seems it’s no longer possible to create a box for FBML pages I only have the option to add the page as a new tab. Is there any other way to tag my wall without using boxes? cheers, Rudi

  41. Pingback: links for 2010-09-14 « Stevens Media

  42. Eduardo said on :

    Now Facebook does not allow to customize the wall. How can I put the code?

  43. Pingback: The Purposeful Techie » Blog Archive » Facebook and Google Analytics

  44. Giuliano said on :

    Hi guys,

    seem like facebook has disabled the box option in fmbl so I am not anymore able to post the code on the wall. Is there any workaround to it? Thanks. G.

  45. ntlgnce said on :

    I wonder if it would be possible to put the IMG tag as your profile pic?

    Perhaps I am dumber then I actually think I am.

  46. Miguel Gaxiola said on :

    Hi, I’ve read everything in this post, very useful. The issue I got is the need to track the wall in Analytics, I’ve read that changing the settings of the static FBML to ‘Add Box’ and ‘Remove Tab’ but in my settings it does not appear, only appears ‘Add / Remove Tab’ how can this be done. Any help is very appreciated and thanks for saring this with the world.

  47. Dale said on :

    Thrilled I found GA solution. I totally understand where to embed Your generator code on page(s).

    Server side upload: would that be the actual GA code generated by Google or
    the one that I got from your Generator?

    Please Advise 🙂

  48. Angelica Blatt said on :

    Where do I paste the code? I need help.

  49. Eric Pena said on :

    Facebook has removed the Box. Does this mean we can no longer track the Wall? Or I’m missing something?

    Thanks!

  50. marlen said on :

    Hello,

    Have you found a new way to track FB pages with Google Analytics now that FBML boxes are no longer available on FB ? I’d be very interested to know !! 🙂

    Thanx

  51. X456x said on :

    guys is it possible to Modify the script to work with Other Analytics Providers ? I don’t want use GA

  52. Pingback: 8 Things You May Not Know About Facebook -XTmotion-Web Development, Web design & Digital Marketing Blog

  53. Pingback: El código fb:google-analytics no funciona en Fan Page de Facebook | UnosTips.com

  54. Temizlik Şirketleri said on :

    Somebody please tell me is it possible to do same thing but for user profile at FB?

  55. Mana said on :

    Excellent tip. Any new solution for tracking wall visits now that Facebook got rid of boxes? Thanks!

  56. Michael said on :

    I was trying to add analytics for facebook pages but couldn’t completed the process please show the step by step procedure for this…
    thanks

  57. Pingback: Few Web Insights – eMarketinGuide.com | Top 10 Google Rankings

  58. Pingback: How to setup Google Analytics on your Facebook fan pages | LaDart Creative Inc.

  59. Kylie said on :

    Thanks for sharing the info. its nice to see a proper replacement to Facebook insights for ages.

  60. Pingback: Google Analytics – Statistiche per facebook | Robots.txt: User-agent: * Disallow: /

  61. Fabian said on :

    Hi,
    I was wondering why you’re working with: utma, utmb, utmc and utmz. If I use your script within my tab-app Facebook doesn’t track referals either, do they?

  62. php-manual said on :

    @Fabian Once setup correctly google analytics tracks referals, country, visitors and you can even set in-page analytics (new feature on google analytics). In short it should work just like google analytics on any web page / website.

  63. Fabian said on :

    @php-manual: Thanks, I tried to refactor and improve this whole thing and I don’t understand these lines, but i ll try to implement them either.

  64. Fabian said on :

    What’s with this comment? Did you fixed this?
    // Problems with duplicate array keys here!

  65. Pingback: Add Google Analytics Tracking to Facebook | Gabe Kassel

  66. Candy Bradley said on :

    It seems I need some help! And I seem to have lost some of the pages with instructions and don’t know where to go to get them…

  67. Fabian said on :

    Dudes, can you please contact me for merging our sources.

  68. Pingback: 5 Facebook Advertising Tips | the steer blog

  69. rhondal reames said on :

    cool

  70. tonya clyburn said on :

    this really works!!!!!

Comments are closed.