I'm currently using jQuery to record each click on a Facebook share link on my site, but I'm looking for a more accurate solution. Instead of recording the clicks, I'd like to record the actual "shares". Is there a way to get a response message back from Facebook after the user shares a link?
I came across this today: http://graph.facebook.com/http://stackoverflow.com
It returns a total share count for a specified URL. I have unique URLs for each user in my application so I can track their shares easily by using this.
It also works for twitter: http://urls.api.twitter.com/1/urls/count.json?url=http://stackoverflow.com
For as long as it remains active, you can use the Facebook "Feed" dialog rather than the "Share" dialog to ALWAYS get a share confirmation. (This applies to the Javascript Facebook SDK.)
Here's my understanding of the differences between the two:
FB.ui({
method: 'share',
href: 'http://stackoverflow.com/questions/5363517',
}, function(response){
console.log(response)
});
If the user is LOGGED IN and authorized your app:
response
variable: {post_id: "10205041067000110_10205045578512895"}
.response
will be null.If the user is NOT LOGGED IN to your app (they still need to be logged into Facebook):
response
variable will be null regardless of whether the user shared or did not share.Thus, if you absolutely need the share confirmation, you have to ask the user to login first. This may not be a problem for your app, but in my case this added unnecessary friction to the sharing process.
(Deprecated but still active)
FB.ui({
method: 'feed',
link: 'http://stackoverflow.com/questions/5363517',
caption: 'Test Caption',
}, function(response){
console.log(response)
});
IRRESPECTIVE of login status (w.r.t. your app; they still need to be logged into Facebook):
response
variable returned by Facebook will have the post id: {post_id: "10205041067000110_10205045578512895"}
.response
will be null.Using this method, you will always be able to tell whether someone posted or not, regardless of their login status.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With