Question

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>
Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top