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

    I have installed this on my server, followed the steps and added a box via Static FBML to my Wall page. But now I also have a tab on my page for the same as the box. I’d like to remove that.

    Actually, what might be most helpful, would be a separate entry outlining how to get this to track your Wall visits. I think i did it right, but the procedure still feels vague (ie, I don’t know what to put into the Page Link variable, and I am not sure that I used the right thing in the Domain on Analytics var – I used facebook.com/chesterbullockphotography, which is what I entered into GA).

    Can a few people go to my page so I can see in a few hours if it is working right?

    facebook.com/chesterbullockphotography

    Thank you.

  2. Chester Bullock said on :

    Oh, and I should have said a big Thank You for putting this out there and letting us know it is possible.

  3. iphp said on :

    @Meredith, don’t worry about the longer string. The strings generated for google analytics are just to help you track which pages are being visited. Give google analytics some more time also try this trick if you have not already.

    For those who can’t wait for 24 hours but have waited for more than 10 hours, you might see new stats pour in. On the dashboard you can change the date range by clicking on the down arrow.

    @Astrid, @Jeff, thanks and you are welcome.

    @Eduardo, yes you will have to wait a while before this goes away.

    @Andrea, If you want to make sure that the code you generated is correct. Just copy and paste the code within (quotes) ‘ ‘ after src= and put it on your browser. You should be redirected to google analytics and you will get a blank screen (because google image is a 1*1 pixel size. This is correct and not broken. Make sure you enter your Analytics code correctly.

    I have appended this article (updates at footer) with an image showing where the code should be placed.

  4. Donna Hoffman said on :

    Thank you for the insight, I will check it our further

  5. keyur said on :

    hi,

    how do you get the proper url for your facebook fanpage.. my fan page’s url is very different…

  6. Josh Premuda said on :

    Just tried it. Would love if some of you click this link to see if I get any tracking info tomorrow (I did this on a test page). Thanks!

    facebook.com/pages/currentblend/314074708131?v=box_3#!/pages/currentblend/314074708131

  7. Christer Hillorn said on :

    Lovely! Thanx for sharing and insightful comments

  8. Dmitry said on :

    Yes, the information good. Perfectly

  9. Creative Ideas said on :

    Really useful and fresh info. Thanks!

  10. Andreas Sefzig said on :

    Great article, thanks! Using iframes (this is possible in Static FBML pages via js-strings, regardless of what the documentation says) one should be able to integrate an elaborate click-tracking as well.

  11. Arnold said on :

    Hey, great article. Tried it out.. Hopefully I did it right. Here’s my fan page link to to test.

    facebook.com/pages/San-Mateo-CA/Beard-Papa-San-Mateo-CA/192542081720#!/pages/San-Mateo-CA/Beard-Papa-San-Mateo-CA/192542081720?v=wall

  12. Francois said on :

    Excellent

  13. Twilight fairy said on :

    seems like a great way to get analytics! will try it out for sure.. FB insight is hardly any use

  14. Reiner said on :

    Thank you for this HowTo! It’s delicious!

  15. Chris Brashear said on :

    Amazing. Code implemented as directed and capturing data 15 hours later! Great work guys!

    @chrisbrashear

  16. Sourav Sharma said on :

    Will love to try and see how it goes..

  17. Kati said on :

    This is great info, thanks! Do you know if the Analytics click tracker will work, even though javascript is not enabled? google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55527

  18. K Cortez said on :

    I placed this on a fairly high traffic FB page. Grace Potter and the Nocturnals (hot band you should definitely check out).

    facebook.com/GracePotter

    It’s on the wall and the “non yet a fan” landing page

  19. kmp. said on :

    just installed here. thanks for making this possible!!

    facebook.com/pages/Vivo-Girls-Sports/191965328828

  20. Tim Ware said on :

    Great post, and thanks. I’m not getting GA to see that the tracking is installed. I pasted the code at the very bottom of the Static FBML page.

    In GA, I set the “Website URL” to http : / / www . facebook . com

    Where I’m confused is how to direct GA to the Static FBML tab page, the URL of which is “http://www.facebook.com/HYPERARTS?v=app_7146470109”

    Should the “Default page” setting in GA be the full URL? I’m definitely missing something!

  21. PaGo Marketing said on :

    Thank you so much for posting this, great idea!

  22. coreytess said on :

    OMG! Love it! But why is there a slice of lemon in your latte at the top of this page, that would taste so nasty! Anyway, I will add tracking to my FB page tomorrow using this.. how awesome!

  23. iphp said on :

    Thanks for the positive comments.
    @Chris, @Cortez thanks for sharing with us that your tracking is working. It should encourage more folks to wait if they have setup things correctly.
    @Keyur, to get a custom URL, you will need about 25 fans or more.
    @Andreas, we think Facebook is going to get rid of iFrames in staticFBML at the end of the month. We wouldn’t be able to do what you are thinking of anyway as an iframe will not have access to the rest of the comments.
    @Kati, Good thinking but it wouldn’t work as the script is complicated on Google Analytics. We will have to re-write the JS to FBJS.
    @Tim Ware, We definitely learned a thing or two from your blog posts on HyperArts. Keep up the great work! I had a look at your fan page. It looks the server is returning the results correctly. Please give Google Analytics some time to show you the latest visits.
    @coreytess, Try it 🙂

  24. Andreas Sefzig said on :

    @iphp: Of course one cannot grab the users information dynamically, but at least you can track certain clicks this way. Tried it yesterday, works a charm. Why is it you think facebook will get rid of iframes in SF? I come to the same conclusion (which is why I did not sell this to clients yet), still my opinion/fear is not based on facts but the thought that the js-strings-technique is an exploit… Any elaboration of yours on this extremely interesting issue would be great!

    Thanks 🙂 P.S. Great blog!

  25. Jesse James said on :

    Such a simple yet powerful suggestion. Thank you very much for posting it.

  26. Patti Fousek said on :

    Great workaround! It’s a shame Facebook Insights lack so many features that marketers really need to track. I’m going to give your tip a try.

  27. Naomi said on :

    Oh wow! This is awesome! Thanks for providing this valuable resource! I’m viewing my Facebook fan page stats now. Lots of peeps on Facebook Friday nites! 🙂

  28. Tim Ware said on :

    @iphp Thanks for the kind words! And, btw, the GA is working now. I had to log off and then back on to see what was *really* happening. Cheers….

  29. Pingback: beyondwords | a blog for professional writers, editors, and designers » Blog Archive » 140+ Tweet Feed: Feb. 20-26

  30. Bridget said on :

    This is excellent! I have been waiting for something to help me track stats better than the Insights. I am so grateful to you for sharing! Also, I am currently tracking the wall. At first it read “Tracking Unknown” in GA. However, after 48 hours, I am now viewing stats. So for those of you with this message, just be patient!

  31. Michael McCloskey said on :

    This is VERY cool! We just did this in Flash a couple weeks ago and it looks like you guys are doing the same thing for FBML. Excellent work guys!

  32. Pingback: Web Analytics Tracking on a Facebook Page | Gilligan on Data by Tim Wilson

  33. Pingback: How to integrate Google Analytics to Facebook Fan Pages | AwardSpace Blog

  34. Hagan said on :

    Hi Guys

    thanks for sharing that. Great stuff.

  35. Philippe Mochamps said on :

    Thanks for the code…and the long and repeated explanations !
    Very useful, I was looking for this kind of tool for months

  36. Lucy Griffiths said on :

    Thanks for sharing this. I will definitely be giving this a go on our Facebook page.

  37. Big City News said on :

    So, all implemented and waiting for the Googlers to update the stats. Just need some traffic for that, can you guys help a little please?

    facebook.com/pages/Big-City-News/137362123910

    Thanks 😉

  38. glenn said on :

    Thanks, this is really cool! Added it to my page. The question then becomes, how (if possible) does one track paths thru the page tabs… engagement if you will?

    facebook.com/street.artists

  39. Dan C said on :

    So will this track the actual people who visit my facebook profile? For instance, I would be able to see their names and the times they checked my profile? This probably sounds like a horribly obvious question, but I am not the most technically savvy individual! Thanks in advance for your answer 🙂

  40. Gary said on :

    I’m curious if it’s possible to do this in conjunction with the stream.publish API method? We’re writing an application that allows an individual to post a custom swf to a friends wall. We like to be able to use GA to track how many times that swf is played.

    Is there a way to accomplish that with this method? As yet, I have been unable to determine how to pass the necessary information through to the stream.publish method.

    Thanks,

    -Gary

  41. e-chasse said on :

    Hello, first of all thank you for this tutorial.

    Unfortunately GA is not receiving any data from my fan page (I included the image on my “landing page” as well as on the wall). I waited well over 72h.

    Can someone tell me if the code on my page seems to be correct?
    facebook.com/chasse.actu

    Thanks in advance. 🙂

  42. iphp said on :

    @e-chasse, I had a look at your facebook fan page. I see that you have hosted the code on your server. It looks like there is some kind of issue causing a script error. Did you alter the code? You are free to use our hosted version if you dont want to debug.
    @Gary, Interesting idea, do give it a go and let us know if it works out for you.

  43. Rob said on :

    Since I’m no developer, I may have taken the more difficult “Advanced” path, but like the idea of seeing the traffic on my domain GA as well. I copied the code into the following location: my-domain.com/fbga and modified the code to reflect that location, instead of your servers. I then went out to GA and saw visits, but assume they came from your servers before I made the switch. How, other than waiting, can I determine if I did this right?

  44. Vishal said on :

    Gr8 Post .Very Excited after reading this post .
    Still not successful to configure it. Need your help

    have completed two steps. First created google analytics account for Facebook Fan page(http://www.facebook.com/panchkula 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(have changed the image from yours to mine). When I have checked status from Google Analytics, I am getting tracking code is not installed message. What to do now ? have already waited for 3-4 days.. my facebook fan page is : facebook.com/panchkula

  45. e-chasse said on :

    @iphp, Thanks for checking my page. I tried to generate a new code and now it’s working perfectly. The only thing that differs from my previous attempt is that I changed my facebook profile from “facebook.com/chasse.actu” to “www.facebook.com/chasse.actu” (and generated new tags based on that). About one hour after adding the “www.” it was already collecting data.

  46. Rovalou said on :

    Can you tell me the difference to this?

    wiki.developers.facebook.com/index.php/Fb:google-analytics

    Is it for Apps?

    thanks

  47. iphp said on :

    @Rob, to determine if you have setup things correctly, visit the img location on the code generated by your browser and it should redirect to Google analytics and show you a blank page
    @Vishal, It looks like there is no tracking code installed on your fan page. Are you sure you have placed it correctly?
    @e-chasse, That is strange but I am glad you got it working.
    @Rovalou, Yes, that link is just for apps. If you need to track fan pages this is the only way to get Google Analytics working.

  48. ayon said on :

    Great info! I have applied this to my band’s facebook page and it works like a charm!

    I’m just wondering whether this would work in a similar social networking site such as Myspace? I pasted the custom image tag using your generator but it appears as a broken image on Myspace alone.

  49. Sam said on :

    Presently we are tracking our facebook activity through our main google account. We can record visitors coming from there aswell as the ecommerce feature installed so we can see revenue generated from facebook. I’d like to gain a better knowledge of what pages, links etc are clicked on facebook to get to our site, so your method seems like we would acheive this.

    However, my concern is that i wont beable to setup the ecommerce piece using your method. Do you know if this will be possible or not, or even have tried it yourself? Thanks. facebook.com/dennis.kirk.fb

  50. ricer said on :

    You cannot add FBML to your profile. Only to a page (as the title of this article mentions). On your profile you have use “profile HTML” app – adding the google image to this box results in the image being encoded / changed as facebook caches the image. The info for profile HTML says that “facebook will alter you HTML – images in boxes will be reduced and cached by facebook”.

    so no.. I dont think this works on a profile.. But it works on a page.. but if anyone can tell me how to get FBML onto a profile I will be interested to find out – or if you think it does work explain how you did it and your results

    thanks
    steve

  51. Pingback: 4 Ways To Monitor Your Facebook Page Traffic

  52. Social Media SEO said on :

    When adding the analytics to your “Analytics Code” field on the code generation tool you’ve provided, do you just add the portion that is UA-XXXXXXX-XX, or are you suppose to add the entire block of javascript?

    I’ve added the code to track both my custom landing tab for non-fans on my Facebook Fan Page, and also to track the wall of my Facebook Fan Page at >> facebook.com/SocialSEO

  53. Social Media SEO said on :

    For self hosted WordPress blogs, you can add this tool to your own server by doing the following:

    1) Download and unzip the self hosted server file provided by WebDigi
    2) Unzip the file once you’ve downloaded it
    3) Upload the entire folder to “public_html” directory for your WordPress blog
    4) You should now be able to find the tool at yourblogname.com/fbga-version1.1

    Hope this helps someone!

  54. Corey said on :

    I don’t fully understand step 3). Can someone enlighten me?

  55. iphp said on :

    @Corey, Please take a look at the screenshot. This is where the code will go http://www.webdigi.co.uk/blog/wp-content/uploads/2009/06/adding-img-tag.png
    @ Social Media SEO, thanks for sharing your wordpress idea. I have not tested this but hope it helps someone. Also, yes, just add UA-XXXXXXX-XX to the tool.
    @ ricer, This method can only be used to track places that you have access to make source code edits and img tag. Which is all of Facebook custom fan pages, wall, etc at the moment.
    @ ayon, I have not tried this on MySpace. Are you sure the UA-XXXXXX-XX was correctly placed?

    Thanks for all your comments, I will try to answer them as I get the time.

  56. grooby dood said on :

    This is an excellent and ingenious Tool! Bravo and thank you very much for sharing!

    Another cool facebook tool people might like is Facebook Purity fbpurity.com It basically cleans up your facebook homepage newstreams from all the spammy annoying stuff.

  57. Ondra said on :

    Hello! Thanks a million. Gives me very good idea of what is going on in my pages.

  58. Jennifer said on :

    Hi everyone! Thanks so much for this post. I was hoping someone would come up with this solution!
    I run the facebook page for a movie starring Cloris Leachman & Tara Reid called The Fields (http://www.facebook.com/thefieldsmovie). I’ve been looking for something like this to test out our marketing on facebook. I just put it on tonight and we’ll see how it goes. Thanks again so much–this is amazing!
    -Jennifer

  59. Lecie said on :

    Thanks so much for the how-to. Google Analytics is still showing the tracking status as not installed – I’m hopeful that it will work though. Would you mind giving it a check? Am I supposed to see an actual image? (Facebook /pages/Lecie-Gallery/301608373343)

  60. Concrete Floor Coatings said on :

    Very nice article

  61. Andrew Coppola said on :

    Thank you for this! Worked great.

    This same method also works for tracking Craigslist posts.

    I haven’t tried it on MySpace yet but I don’t see any offending characters in the img url that would prevent it from working.

  62. social network web development said on :

    This is an excellent and ingenious Bravo and thank you very much for sharing!

  63. Fitz said on :

    I’m wondering about tracking goal conversions originating from Facebook but then converting on our primary website. Google explains how to track analytics across different domains here:
    google.com/support/analytics/bin/answer.py?hl=en&answer=55503

    But this requires adding 2 lines of code to the on-page analytics code on both sites. Using your hosted service does not allow us to do this. Do you think it’s possible, on the backend, for you to add the additional two lines of code?

    pageTracker._setDomainName(“none”);
    pageTracker._setAllowLinker(true);

  64. brian cors said on :

    Greetings, all!

    Trying this out for the University of Michigan Museum of Art [UMMA].

    Can you please try the following pages?

    facebook.com/ummamuseum
    facebook.com/ummamuseumstore

    Thanks!
    [b]

  65. BeththeIMVA said on :

    I’m researching this for my own use and for an article about enhancing your Facebook Fan Pages for Small business.

    But I have a few issues, non-technical people and perfectionist nancies like me, can’t overlook.

    It’s unclear, and Lecie already brought it up, whether the google analytics status will change or not. Please let me know, I set mine up and I see “Tracking NOT Installed”.

    Also I’d like to link your website in the article as the source, let me know if this is okay with you.

  66. Debbie Hemley said on :

    After several attempts, mine is working!
    For some reason it did not like being on boxes tab and shortly after putting on wall, it started pulling in data. Wow, is this ever a great example of social networking and community. Thanks!

    facebook.com/webermedia

  67. iphp said on :

    @BeththeIMVA, Eventually (a couple of days) the status will change to “Receiving Data” and you will see a green tick which should keep people happy! We are happy to have you link to this article.

    @Debbie Hemley, You are welcome, Thanks for sharing your experience.

  68. Vytautas said on :

    It seems that when using code on my own server it doesn’t work because i tried yours hosted code and it works just fine.

    However, here’s generation script working all fine on my server: gosocial.lt/fbga/

    Have any ideas what’s the problem?

  69. Francesc Gómez said on :

    Great stuff!! It works. Thank you for sharing!

Comments are closed.