Search code examples
facebookfacebook-graph-apifacebook-javascript-sdkfacebook-sharer

Tracking Facebook shares of a range of links


I'm looking to track shares of a range of links of my site. There are two tricky things here, though:

For one, the links could span multiple domains (so using the FB.ui share dialog and tracking the callback is out).

Second, links are specific to users for my site

So, an example url might be http://example.com/share/unique-id-goes-here

I know there's a Graph API query parameter (?id) but that'd only track one of the URLs and I'd like to avoid sending (potentially) hundreds of requests at the API all at once to get back sharing info.

Is there anyway to do a wildcard search? I'm open to other suggestions as well!


Solution

  • There is no way to do a wildcard search and no such option exists in the documentation. Your best bet is to look into Facebook Insights and attach ref params for links that you own.

    Your second option is correcting this statement

    I know there's a Graph API query parameter (?id) but that'd only track one of the URLs

    You can track more than one id with the ids param

    https://graph.facebook.com/?ids=http://www.stackoverflow.com,https://www.youtube.com

    Response

    {
       "http://www.stackoverflow.com": {
          "id": "http://www.stackoverflow.com",
          "shares": 27967,
          "comments": 4
       },
       "https://www.youtube.com": {
          "id": "https://www.youtube.com",
          "shares": 8709432,
          "comments": 9
       }
    }