Tracking user engagement on Facebook fan pages

In our previous blog post we showed how to setup Google Analytics for Facebook fan pages. The article was very well received and highlighted the importance of improved analytics. Please review the older article for detailed instructions on how to setup Google Analytics. Here are a few interesting concepts which will help you build better Facebook fan pages and also take your Analytics information one step further:

Fans versus Non Fan activity

An interesting way to look at your Facebook fan page activity is to split them with activity by your Fans and non fans. To do this, we need to use segments in Google Analytics to split activity into Fan and Non-Fan activity. You can create a segment based on pages visited by your user or specific event.


Using segments to track Fan/Non Fan activity

We will need to use FBJS (Facebook Javascript) and the tag <fb:visible-to-connection>. The tag will allow us to display a section to Fans and another to Non-Fans. We have managed to use this to create a single action button but calling different FBJS functions depending on whether the user is a fan of the page or not. Once a Javascript function is activated, the appropriate tracking image has to be shown to log the visit correctly on Google Analytics. Displaying this tracking image causes a hit to be registered on Google Analytics and this can be used to segment traffic. Visit our tracking page to get the code and see this in action.

Tracking activity on forms and on your pages

This is a good method to track user engagement with the Facebook page. Several users might visit your Facebook page but only a few might actually engage with the form. When your custom Facebook fan page loads, Facebook does not activate the Javascript you have written. This is only activated when a user performs an activity. Something like clicking on a button, clicking of your form, playing a video, entering some details onto the form, clicking on a button of your carousel, etc. This is a good opportunity to track activity on your page. All you have to do is use a script tag like the one used in the Advanced tracking page.

Goal and Funnel Visualisation

This can be a quite powerful tool, you can track for example how many users visit your contact page, how many then proceed to engage with the page and how many eventually click on the contact button. Here is an example of a funnel visualisation.

A simple funnel visualisation

A simple two step funnel visualisation

The above two step funnel visualisation shows you how many users visited our contact page and how many proceeded to submit the form. This could have also been made into a three step funnel displaying how many visited the contact page, how many clicked around and how many actually clicked the contact button.

Tracking Purchases or clicks on your fan page

To track clicks which can be purchases, clicks on links, etc. We generate a tracking code for each action that we want to track using our trusted Google Analytics code generator. We then load this image location on click of a button, or link, etc using the usual onclick event handler.

In conclusion

These techniques require some knowledge of Javascript and a reasonable understanding of how the image technique lets you work around Facebook’s Javascript restriction. You can get the complete source code to how we segregate fan and non fan visits, etc here. We are a web development company and will be happy to help you out with your unique tracking needs on your Facebook page. Please share your thoughts, comments and ideas on how to track user behaviour in more depth.

Also read...


  1. Jonathan Creamer said on :

    The fb tab tracking works great. thx. i’ve got it running on my own servers. it was so easy that I thought i must be doing it wrong.

  2. Claudio said on :

    Hi, I would like to split fans and non fans without having to get them to click on a button. Is this possible? Just by visiting the page it would be cool to know who is a fan, who isn’t and possibly even who is logged in…

    Is there a way you can think of?


  3. Arkid Mitra said on :

    I will be reblogging this at Will put the credits for sure.

  4. Jennifer Hitchens said on :

    For the Goal and Funnel Visualization to work it requires a vanity FB URL correct? Otherwise the domain includes variables that will not work with the analytics goal set up?

  5. jeannette said on :

    hello there! thank you so much for posting these 2 blogs on google analytics and facebook. i’m wondering if there’s a way to track visits to each tab within a facebook fan page, and i’m not able to figure out how to do that. do you have a post that details that? thanks again!

  6. Le_Wiss said on :

    First, thank you for sharing this really nice work to the community. I wonder if there is a way to track Events. Not as a Virtual Page View. But using pageTracker._trackEvent(event, category, label)” ?

  7. Cullen said on :

    Thank you for putting this together. I am trying to set this up to work with a link but I’m not sure how to set the onclick. Could you please give an example for this?


  8. iphp said on :

    @Jennifer, Vanity URLs are not required

    @jeannette, You will be able to track visits to each of the tabs if you have different links generated using the Facebook Google Analytics generator (FBGAT)

    @Le_Wiss, No, Facebook will not allow this kind of a script to run easily. You might be able to get it done after an user action like a click, etc.

    @Cullen, You will be able to get examples here the code is on the last link

  9. Le_Wiss said on :

    (Maybe I just said it the wrong way) I mean :

    Your method is sending virtual page views to GA and populates the common “Content reports” with the URI’s we chossen when generating the image insertion using your Form.

    I wonder if there is a way, using your method, to send events to GA and populate the “Event Trackin” report. Not specifically using a JS call like pageTracker._trackEvent(event, category, label) that I understand should not work. I just refered to.

    For the moment, looking at the code that is outputed by your GA code generator, we can’t because your script isn’t waiting for this kin of parameter.

    The idea is to append something like this to the final GA gif call :
    &utmt=event&utme=5(the-event*the-category*the-label). I think it could be as easy as adding a new field in your Form and appending it to the final GA gif call.

    What do you think of this ? Do I missed something ? Am I wrong ?

  10. Nadine said on :

    @jeannette, You will be able to track visits to each of the tabs if you have different links generated using the Facebook Google Analytics generator (FBGAT)
    @iphp- but what if the boxes with these links are in not in their tab- will it still trigger the js in the in the boxes when the user goes there?

  11. iphp said on :

    @Le_Wiss, Brilliant! I had the same idea but could not start work on this. Yes, I don’t see anything that would stop us doing this. In fact if you trigger a an event on Javascript, it inturn uses the gif image. Do let us know if you make any progress on this.

    @Nadine, there wont be any Javascript triggered as it is not allowed to run in Facebook. But yes, if the image is on the page it will be triggered. Thanks for answering the question asked by jeannette!

  12. Gav said on :

    Hi guys,
    Thanks for this post and the also keeping replying to comments – I hope you’ve got some business out of it all!

    I would like to pay third parties per fan signed up, and have them track this through (ideally) a third party tracking system. I’m happy to use whatever (affiliate network, GA, etc) but whatever is simple. Eg have a box saying “sign up to like” and I could pay them a quid per user signed up. I would like the affiliate to be able to track this somehow, rather than just relying on Google analytics referrer strings, any ideas? Obviously you don’t have to actually visit the page to ‘like’ something any more – it would be good to track it.


  13. Kevin C said on :

    I’ve successfully setup the tag and am tracking visits on multiple facebook tabs. Each tab has it’s own unique tag with the page url and page title attributes. In my google analytics view I can see the different urls listed like so:

    I’m wondering how I can change those ugly urls to something more friendly like ‘Contact’, ‘Wall’, ‘Tab Name’ or something like that. I read something about setting up filters in GA but I didn’t get too far.

    Any thoughts or ideas on how to get a more friendly name rather than an ugly url? Thanks!

  14. iphp said on :

    @Kevin, yes, On FBGAT, when you generate links, just put in the URLs Contact, Wall, etc.. That should give you nice looking URLs, you don’t have to match the URL as on Facebook.

  15. Pingback: Bezoek op Facebook pagina’s meten met Google Analytics | Craving

  16. iphone developers said on :

    Good stuff! I really like Google Analytics for my site, and now I can really nail down the details for my clients Pages.

  17. Jean-Philippe Murray said on :

    Bump @Claudio ‘s question at the beggining: would there be anyway to track fan VS non-fan without needing a click? Conditionnal tags somewhere in the FBML? You know, if fan=true then show one, else show other…

    I’m not savvy into the PHP dev kit, but could it be done?

  18. karel said on :

    Hello webdigi,
    thank you for sharing, thanks to you everything works for me like a charm:)
    About tracking user clicks – trigger java after click is allright at FB, right? So we could use google “recordOutboundLink” for tracking outgoing traffic to another sites, or am i wrong? ( thanks a lot, karel

  19. Fabian said on :

    Hey webdigi,
    thanks for sharing. I got two questions:
    1. How do I track outgoing links (e.g. to a product on my website)
    2. How do I configure a funnel (on fb- and ga-site)?

  20. iphp said on :

    @Jean-Philippe Murray, nope, you cannot check if the user is a fan or a non-fan without a click. Facebook does not allow this.

    @karel, you can have links using the element a with href=, etc. But you need an onclick javascript to record this click. It can be similar to the tracking the button click above.

    @Fabian, You can track outgoing links as above message to karel (similar to buttons). This works on the onclick method. To configure a funnel, its a bit tricky, you will need to have better knowledge of Google Analytics. But basically a funnel tracks visits to /landing_page, /contact_page, in a sequence. Just search for this on Google and you will get an idea of how to setup funnels.

  21. karel said on :

    thanks a lot for your advice and help webdigi:) good luck in your business!:)

  22. Fabian said on :

    Hey iphp,
    Thanks for helping. One more question: How to you separate Fans versus Non Fan activity in GA (your image shows two graphs)?


  23. Fabian said on :

    Hey iphp: To answer the question to myself:
    One solution would be to track pagelinks like this:

    In GA I could look for “fan” and “nonfan” inside the page_link to create different segments. But, I think you have a better solution, haven’t you?

  24. Laki Politis said on :

    Hey iPHP. Thank you so much for your hard work on this open source code! It’s such a huge help. I was wondering about the event Tracking option mentioned a little bit earlier. I’ve simply added queries at the end of all my links for know by using FBJS’ [image].setSrc(‘youlink?page=/default.aspx?action=’ + var’); but it doesn’t really give me what I want in GA.

    Any recommendations, or even maybe an update to the open source code? 🙂



  25. Ram prasad said on :

    your blog is nice Good stuff! I really like Google Analytics for my site

  26. MG said on :

    How about using this to track the “like” button? To know how many visitors actually clicked the “Like” button from each traffic source?

  27. Morgan said on :

    My google rep sent me to your blog – I love it!! We just launched this Facebook app for one of our client giveaway/promotions. I would like to specifically track how many visitors to this tab “Like” MurphyUSA and where they’re coming from. I’m not clear as to whether this click event can be tracked (I’ve heard it can’t). ?


  28. iphp said on :

    @Karel, @Ram, Thanks for your comments

    @Fabian, you have to use Javascript (FBJS) to identify if a user is a fan or not a fan. You can see more details on our Facebook fan page under the Tracking tab. On your second comment you picked up the correct approach of creating segments to view both traffic separately.

    @Laki, I think you are on track to get it working. Can you put your simple javascript tracking code on a simple HTML page and load it? This way you will be able to see what image is being requested from Google servers. You should be able to replicate this on your facebook page.

    @Morgan, We haven’t looked into tracking “likes”. It does not look like it is going to be straightforward as this is Facebook’s own like button at the top of the page.

  29. dood said on :

    Im probably wrong … cause Im a total newbie to this and probably confused as to what the hell anyone is even talking about. But crossed my mind a way to track fan/like vs nonfan/nonliker 😀 … would be to set a custom welcome page/tab up with static fbml. Which you might get some false positives … but still might give you an idea of the metrics involved.

    Another approach … being the content only available to fans/likes people ? If you’re able to include something trackable into that hidden content. Could give you some idea about this as well ?

    Anyway, appreciate the article … maybe someday ( hopefully soon ) I wont be so green on this subject.

  30. Facebook user said on :

    Hi. I’ve just installed your Spier for Life application on Facebook, but whenever I click on it I’m directed to this blog. How do I actually get to see who’s visited my page? Thanks

  31. Pingback: A Guide to Utilizing Facebook for a Freelance Career | Bitmag

  32. Julie said on :

    I want to track non-fan pages such as my wall, posts, etc., but I haven’t been able to find instructions on how to do this. Facebook removed the “box” option that they used to have. Does anyone know of any alternatives?

  33. tiffany said on :

    has anyone compared the result from google analytics for fan page against insights data?

  34. Jessica said on :

    Do you know if it is possible to run an image ad through AdWords that goes to a Facebook Fan page and track if someone ‘Liked’ the page after clicking on the ad?

  35. Pingback: Google Analytics for Facebook Fan Pages

Comments are closed.