How to catch action from facebook 'Like' button
-
25-09-2019 - |
Question
Is there a way to catch event of clicking fb Like button ? I don't want to integrate my app with facebook, just need to count clicks of 'Like' . Tried :
$('.fb_iframe_widget').click(function(){
alert("clicked");
});
but without any luck. If there is no way of doing this will I be able to count likes of particular pages when synced with FB API ?
Solution
You must use the xfbml like button rather than the iframe button. After you switch that, do the following:
FB.Event.subscribe('edge.create', function(response) {
// user clicked like button!
});
The facebook event "edge.create" is called when a like button is clicked. I have no idea why it is named that, but that will do what you are looking for.
OTHER TIPS
If that doesn't work, then I think you'd be out of luck, as you can't do anything else because of same origin policy.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow