"link Clicks" of a Facebook Post and how to get its value using FB Graph API?

5.2k views Asked by At

I have a requirement to pull the 'link clicks' count of a FB page post? What Exactly comes under the 'Link Clicks' count? Is it the number of clicks of the link shared in the FB post or is it something else? What insight metric should we use to get the "link Clicks" of A Facebook Page Post? Please suggest!!

2

There are 2 answers

0
Javier de la Cueva On

If you're talking about a page post created for an Ad, you can track click links, please take a look at the docs:

https://developers.facebook.com/docs/marketing-api/click-tags/v2.3

https://developers.facebook.com/docs/marketing-api/tracking-specs/v2.3

If the post has only one link you'll be able to track clicks over that link.

If there is no ad tracking this post, you cannot get that information: https://developers.facebook.com/docs/graph-api/reference/v2.3/post

In that case, you need to use another analytic tool and check referrals (from Facebook).

I hope it helps.

2
Ciprian On

you have posted your question about a year ago, but I want to give some hints, anyway.

This is for the v2.5 api (I am not sure if this also works for v2.3):

for individual clicks:

v2.5/(post-id)/insights/post_consumptions_by_type/lifetime/?fields=values

for amount of individual users who clicked the link:

v2.5/(post-id)/insights/post_consumptions_by_type_unique/lifetime/?fields=values

You should get a result like this:

{
  "data": [
    {
      "values": [
        {
          "value": {
            "video play": 2305,
            "other clicks": 4774,
            "photo view": 58,
            "link clicks": 232
          }
        }
      ],
      "id": "(post-id)/insights/post_consumptions_by_type/lifetime"
    }
  ],
  "paging": {
    "previous": "***",
    "next": "***"
  }
}

Use $result["data"][0]["values"][0]["value"]["link clicks"] to get what you want.

Edit: If there's no link attached to the post the "link clicks" node won't appear. Therefore, assuming you are using php, check isset($result["data"][0]["values"][0]["value"]["link clicks"]) first.

Hope it helps!

Regards!