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

<html>
<head>
<script type="text/javascript" src="jquery-latest.js"></script>
<script src="http://connect.facebook.net/en_US/all.js#appId=197607353625066&amp;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.’);
});
};
});

</script>
</head>
<body>

<div id=”response”></div>
<div id=”fb-root”></div>
<fb:like href=”http://subjekt.com&#8221; send=”false” width=”450″ show_faces=”false” font=””></fb:like>
</body>
</html>

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.');
});

Advertisements

2 thoughts on “Track Facebook Like Button Event

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s