Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect a successful share with the new Facebook Share button

I am using the new Share button on Facebook. Is there a way to detect a share event? I had a look at the FB.Event API but I couldn't find which event matches a successful share.

I used the Share Button documentation page to generate the code I'm using.

JS:

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=xxxxxxxxxxx";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

HTML:

<div class="fb-share-button" data-href="http://developers.facebook.com/docs/plugins/" data-type="button_count"></div>
like image 509
RRikesh Avatar asked Oct 20 '22 19:10

RRikesh


2 Answers

the share button doesn't provide the possibility to track the share event, at least as far as I know. If you want to "listen" to share events, you want to do what Fabio suggest and use the share dialog: https://www.facebook.com/dialog/feed?app_id=APP_ID&display=popup&link=http://example.com&redirect_uri=http://example.com/someone_shared_on-fb.php, or something like that.

like image 176
tattvamasi Avatar answered Oct 23 '22 23:10

tattvamasi


You can try something like this with FQL : Facebook query language.

SELECT share_count, like_count, comment_count, total_count FROM link_stat WHERE url="http://www.mysite.com/some-page"

Check your reponse from this link https://developers.facebook.com/tools/explorer

SO everything a user share and u want a track just hold its url and run a query there will provide count of likes,share and comments as well

Cheers and keep rolling

like image 30
Rahul Gupta Avatar answered Oct 24 '22 00:10

Rahul Gupta