How to detect Facebook Unlike

Hi Guys,

Let me show you how to detect the Facebook Unlike. Without wasting much time lets jump straight to the point.

First up is to get our markup set up

The Markup

Above is just basic markup that is required for your Like button as picked from the Facebook docs.

Next up will be converting our above container to a Facebook like button, here is how its done

The JavaScript

FB.init is the main thing that we should be concentrating on and for us the most important properties will be appId, xfbml

This code should be placed directly after the opening  tag.

 FB.event.subscribe(“edge.remove”,function) is the magic bit. What we are telling FB API is to tell us if user have removed his/her Like for the current URL in href attribute

The Demo

Demo uses my jQuery plugin to generate Facebook Like buttons



Most notable part as stated above is to use fbxml so that we can make use of event subscription. Normal iFrame code doesn’t seem to work with events and stuff.

Important: We can only detect user action on you FB Like button if that happens on your website. If user use their Facebook page to administer their likes and unlikes, there is no way we can tell then.


I hope that this post was useful.

As always if you have anything to add, comments are open and stage is all yours


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.