I have integrated facebook Like button in my facebook application using the iframe method.
I am not able to subscribe to Like event, even using
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You just liked '+href);
});
I understand this works for <fb:like .. but this method opens a comment pop-up whenever Like button is clicked, which I don't want to happen. If this can be avoided (making it work like iframe method), I am happy using this method.
I referred to https://stackoverflow.com/a/3718992
but not sure this is the issue.
Can anyone please guide?
Thanks
Simply stated, is it possible to use
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You just liked '+href);
});
for iframe method of integrating Like ?
Well, if it opens a pop-up it means you are subscribed.
Edit the second line in the javascript code to call action after user clicks like (now it calls pop-up).
Related
We want to give our site visitor option to like our Facebook page from our website. However we want to track the "count" of how many like we get from this page. It is indeed our campaign page and we want to track how many visitor we have verus how many like we generate.
I did google and maybe I don't know how to search it, but all I got is general count of like or how to get like button. But my need is little specific, we just need how many like our campaign generate. Period.
You can do some analytics at your end-
The XFBML and HTML5 versions of the button allow you to subscribe to the edge.create event in the Facebook SDK for JavaScript through FB.Event.subscribe. This JavaScript event will fire any time a button is clicked.
edge.create is fired when someone clicks a like button on your page to like something.
edge.remove is fired when someone clicks a like button on your page to unlike something.
Example-
var page_like_or_unlike_callback = function(url, html_element) {
console.log("page_like_or_unlike_callback");
console.log(url);
console.log(html_element);
}
// In your onload handler
FB.Event.subscribe('edge.create', page_like_or_unlike_callback);
FB.Event.subscribe('edge.remove', page_like_or_unlike_callback);
And some other ways mentioned in the FAQ section of the documentation: Like Button
I am dynamically generating Like buttons for an app.
I use FB.XFBML.parse(document.getElementById("fbook"))
and can indeed create likes for dynamic pages. All these likes are then sent to my Facebook App. Is it possible to track which of the pages were liked by users?
You could use this:
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
This method attaches an handler to an event and invokes your callback. In the example is the anonymous function.
In this way you can track any like button in page.
$("document").ready(function(){
FB.Event.subscribe('edge.create', function(href, widget) {
...do something
});
});
the above code track the user LIKE the site, how to track if the user SHARE the site?
Please note that "Share" has been deprecated in favor of the like button (see https://developers.facebook.com/docs/share/). The like button has a "Send" component which is basically the equivalent of Share.
Unfortunately, even Send is known to suffer from the problem you describe: It doesn't generate any sort of confirmation or callback. This problem has been reported to Facebook and you can track the bug report here:
https://developers.facebook.com/bugs/275748669167650
When clicking the Facebook Like button on my site I want the user's browser to be taken to my Facebook page. Is this possible?
This is possible.
If you use the Javascript SDK to subscribe to facebook events http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
then you subscribe to the edge.create event and then fire some js to do this:
FB.Event.subscribe('edge.create',
function(response) {
window.location = "http://facebook.com/mypage";
}
);
Hope this helps
Is there a way to catch event of clicking Facebook 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 ?
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.
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.