Track Facebook Like Button Event

Why Track Facebook Like Button Event

Lets take an example of any online Store.

We want to show some coupon code, when user Like my Product.
In That case we need to ”’Track Facebook Like Button Event”’.

”’We can track the Facebook like Activity  ”’
To Track the Activity following Points are Important:

  1. We can Track Facebook Like button Click only by XFBML Method.
  2. ”’FB.Event.subscribe”’ Method is used to Track the Like and Unlike.

Sample Code

<script type="text/javascript" src="jquery-latest.js"></script>
<script src=";xfbml=1"></script>
<script type="text/javascript">
$(document).ready(function() {

window.fbAsyncInit = function() {
FB.init({appId: ”, status: true, cookie: true, xfbml: true});
FB.Event.subscribe(‘edge.create’, function(href, widget) {
$(‘#response’).html(‘You have subscribed it.’);
FB.Event.subscribe(‘edge.remove’, function(href, widget) {
$(‘#response’).html(‘you have unsubscribed it.’);


<div id=”response”></div>
<div id=”fb-root”></div>
<fb:like href=”” send=”false” width=”450″ show_faces=”false” font=””></fb:like>

This Method executes when you Perform Like Activity.

FB.Event.subscribe('edge.create', function(href, widget) {
$('#response').html('You have subscribed it.');

This Method executes when you Perform UnLike Activity.

FB.Event.subscribe('edge.remove', function(href, widget) {
$('#response').html('you have unsubscribed it.');

Share and Enjoy

  • Facebook
  • Twitter
  • Google Plus
  • Live
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
  • Instapaper
  • FriendFeed


  1. I really appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You have made my day! Thanks again!

  2. I’m not sure where you are getting your information, but good topic. I needs to spend some time learning more or understanding more. Thanks for fantastic info I was looking for this info for my mission.