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 or 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.

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...


  1. allison said on :


  2. Nakesha Daniels said on :


  3. christine snoots said on :


  4. Robin MacDonald said on :

    Great. I think that it’s best to know who has visited me.

  5. Katie said on :

    Great. Thanks

  6. Tammy said on :

    good to know

  7. R said on :


  8. Kiara said on :

    totally awsome

  9. Laura said on :

    Great!It is a good think!

  10. GLoria said on :

    This is great

  11. Eric Kirkhuff said on :

    I have setup google, generated the code, but as usual, facebooks stumps me. I setup and FBML page, but cannot add or insert the generated code anywhere. Can you please help me and walk me through why I cannot have a proper FBML page I cannot edit?
    Thank you very much.

  12. Ginger said on :


  13. Robin said on :


  14. Kathy said on :


  15. kalijah said on :

    good article

  16. Pingback: Comment installer Google Analytics sur votre Page personnalisée Facebook | Nicolas Bariteau Conseil

  17. Pingback: Fanpage Customization Secrets – Custom tabs and Applications « Mahesh Narayanan

  18. oliver felix said on :

    good going!!!

  19. Jason said on :

    Wish I could track outbound clicks on my FB page. This will only track visits. Great solution though and one of the few around. If anyone has any advice on how to track outbound clicks on a FB Fan Page, I (and everyone here) would certainly welcome this info!


  20. wildmike said on :

    Great and inspiring article it is!

    One nuance that worries me however is that my GA dashboard suggests that every visitor to my fan page uses ‘facebookplatform’ browser and all visits were made from USA, California, Santa Clara or USA, Virginia, Ashburn 🙂
    As the only visitor I am sure that I am not there. Other information about visitor client is (not-set).

    Can anyone help me fixing that (already tried webdigi and private hosted versions of FBGAT, added debug logging and all seems fine).


  21. Hondus said on :

    All visits are tracked perfectly for me. Thanks so much for this awesome work!

  22. Aaron Brown said on :


    This open source tool and all your hard work is much appreciated!! Thanks for sharing and for being so active in the comments and questions people have posted. I have 3 questions for you and/or the readers out there.

    First, I was curious about filling in the form for the code generation, as well as the info you put into GA on signup.

    In GA: do I put the domain I want analytic for as “” or as “” ? does it matter

    as for FBGAT, when filling in the ‘page link’ field it appears you use a partial URL (ie. “/subdomain.html”). But what about small additions to the URL(cant think of a better way to describe :S )? I’ll give an example. Do I enter:


    Secondly, how can this be made to work for tabs that ‘come with’ the Page (ie. wall, info, etc.)–by which I mean tabs that you cannot edit through FBML tab?

    Finally–just so I understand more fully how this method works–you guys are sneaking GA onto the page by tracking the image that will be added to the page (I see a small ‘broken’ image at the bottom of my page when I add the code). Is your method, essentially, using GA to grab info about the image being loaded/accessed on your FB page, and using that as a proxy for tab visits?

  23. Graeme said on :

    Hi there

    Apologies, I’m a bit of a novice! I’ve followed the steps above for adding google analytics to my facebook page, but…

    How do I actually do this?:

    “Add the entire custom image html tag from step 2 to the bottom of each Facebook fan page that you need to track.”


  24. dmac said on :

    Hi @iphp thank you for this article!
    i wanted to ask you something about the installation:

    1.i downloaded “Facebook – Google Analytics Tracker v1.1”
    2.i made a directory on my server and placed the folder.
    3.i went to index.php
    4.i genertaed the code.

    now one thing ive noticed is that my generated code looks different from yours:

    —–> index.phpfbga.php? are sticked together and when i generate this from your host it shows only fbga.php? without index.php

    will this cause any problems?
    thanks heaps,

  25. Lenwood said on :

    @dmac Yep, you’ll need to change that line. It’s calling a file to pass parameters to. index.phpfbga.php isn’t a real file, so this will produce nothing. You’ll want to change it to fbga.php (remove “index.php”). HTH.

  26. michael said on :

    thanks for the great work

  27. vernon savoini said on :

    good going

  28. g said on :

    how do you do this?

  29. Lucas said on :

    Great help!!

  30. brent jones said on :

    thanks for the info very helpfull cheersssss

  31. susan said on :

    Very interesting…

  32. helen said on :

    This is really good info.

  33. JESSICA said on :

    this is a really great idea.

  34. John said on :

    Yep, brilliant!

  35. joanne said on :

    great idea..!!

  36. Gaynor said on :

    yeah cooooool

  37. claire said on :

    🙂 xxx

  38. YOMAN said on :

    wtf!!! this is just GREAT!

  39. maegan said on :

    yep it’s great

  40. maegan said on :

    it’s awesome

  41. Annie said on :

    Informative comments for those who wish to access this info

  42. deb said on :

    Thanks this is great….nice to know if a certain person wants to contact me…appreciate your effort in developing this app

  43. john england said on :

    this is a good idea

  44. sharon said on :


  45. Shepherd said on :

    Nice one

  46. Fred said on :

    This is totally brilliant, thanks for opening up to the world.

    Has anyone tried tracking the Wall page since the Facebook introduced the New Layout? I don’t see a way to load the FBML on the Wall anymore. Anyone come up with a workaround?

  47. john said on :


  48. Gabriele said on :

    @ iphp

    I haven’t read all the 313 comments to telling you the truth ; ) but I was looking for the information on how to set the image I prefer (among your gifs) to load on the fanpage tab – I’m using the FBGAT pack on my server.
    Please give me a hint! ; )

  49. Pingback: Quora

  50. Matt said on :

    great STUFF!!

  51. frank said on :

    so, since facebook removed boxes, we can no longer use this to track visits to our wall???

  52. Brad said on :

    good info!!!

  53. Andy Bradshaw said on :

    Brilliant posting, I have been designing facebook pages for some of my clients, will certainly look to add this functionality to the pages.
    Site bookmarked!

  54. Kurt said on :

    iphp –

    Fred on 1/12 asked “Has anyone tried tracking the Wall page since the Facebook introduced the New Layout? I don’t see a way to load the FBML on the Wall anymore. Anyone come up with a workaround?”

    Does your suggestions work with the new layout. I think this stuff is some of the most brilliant stuff I have read in awhile. Thanks for the updates.


  55. Pingback: How to Set Up Google Analytics for Facebook Fan Page » Fiphy.Com – Internet, Technology, Google, Facebook, Microsoft and Apple News -

  56. Armin said on :

    @Gabriele: I couldn’t add a box to the new fan page layout … Maybe I’m missing something. Weren’t they supposed to be discontinued anyway? Anyone got an example?

    Also, as far as I can tell, facebook is running the images through it’s proxy … so no direct link us/google … Can someone clear this up please?

  57. Domicio Neto - SEO said on :

    I have same problem that Fred and Kurt.

    I need new solution about the Google Analytics on Wall of Facebook Page.

  58. Sam Steiner said on :

    @Kurt – with the new layout there are no boxes anymore. This means, there is no way to integrate StaticFBML on the main wall anymore – which is a bit of a shame – this method would have been a really good insight next to the Facebook page insights which don’t show very much details.

  59. mahesh said on :

    @sam Steiner

    You are right , there is not more boxes now 🙁

  60. Pingback: 35+ tips and tricks for sexier analytics

  61. Leander said on :

    Hi There,

    I have a question. I made an custom image html tag and have to add this to the bottom of eacht Facebook fan page that i track. But how do i do that?
    Can someone help me?

  62. Pingback: Designing A Facebook Fan Page: Showcases, Tutorials, Resources

  63. Tara said on :

    Nice Post! Very informative.

    Has anyone come up with a solution to track the Wall page since the new layout?
    Facebook should look into providing this feature 🙂


  64. Ledigitale said on :

    @ Kurt – So basically you are saying that this method is not longer applicable to track the wall right?

    I tried to set it up and I was able to get it working for a static page. However the StaticFBML is no longer available for download directly from Facebook. I got it here and was able to track a new page, which I called “myPage 1” but this is not very handy as most of my traffic comes from the wall.

    Has anyone found another method for integrating Google Analytics into their wall page?

    Great resource by the way, pitty it can’t track the wall anymore.

  65. Pingback: Designing A Facebook Fan Page: Showcases, Tutorials, Resources | W Design Love | Graphic and web design blog

  66. Pingback: Measuring the Success of Your Social Media Activities « eBusiness Buddy

  67. Todd said on :

    Not a techie and I got it going so thanks a ton.

  68. Arona said on :

    Actually I want to track and have it in my Google Analytic account each time a member click on the facebook link on the newsletters.

    Yes I generate the code for facebook tracking and I paste it on the bottom before the end body.
    Is it mean if I clic in an any facebook link on my newsletters it ll show on GAnalytic

  69. Pingback: Google Analytics for Facebook Fan Pages! « A. James Editing

Comments are closed.