Dhaval Pujara
Dhaval Pujara

Reputation: 21

Facebook social plugin share button

I am using a Facebook social plugin share button, I want to capture the event whether the user shares the event or not.

Is there a way to check whether the user shared it or not using plugin only?

Upvotes: 0

Views: 106

Answers (1)

James Craig
James Craig

Reputation: 6864

Using the FB.ui method provided by the Facebook JavaScript SDK, you can pass a callback as the second argument and check for the post_id on the response object.

FB.ui({
    method: 'feed',
    link: 'http://www.example.org/',
    picture: 'http://placehold.it/400x400',
    caption: 'Title',
    description: 'Some description...'
}, function (response) {
    if (response.post_id) {
        // This post was shared
    } else {
        // This post was not shared
    }
});

More information can be found in the Facebook share documentation.

Upvotes: 1

Related Questions