2

After I make an ads for my post on facebook ads manager. Facebook Ads Manager show me how many comment belong to this ads. This is very important for me to verify the effective of my campaign.

In programing aspect: Is there's any way to count number belong to my ads like Facebook Ads Manager (I describe above). I have used both Java Facebook Ads SDK (Ads Insight module from https://github.com/facebook/facebook-java-ads-sdk) and Graph Explorer Tool, they both return "comment" field or "like" field not existed Please help!

lamxung55
  • 61
  • 1
  • 7

2 Answers2

2

You can't get comments nor reactions from Marketing Insights directly.

I stand corrected. If you have access to an ad_account insights, then you can use Marketing API to get a post's comments directly. Thanks @lamxung55

Let's say you have and ad_id of 123000000

If you have a token with ads_management or ads_read permission, you can make a request to the Marketing API such as

/123000000?fields=creative.fields(effective_object_story_id),insights.fields(actions)

This will give you the effective_object_story_id which is the object_id of the post ({page_id}_{post_id}), and its insights including its actions broken down by action type. For example:

{
  "creative": {
    "effective_object_story_id": "456000000_789000000",
    "id": "123000000"
  },
  "insights": {
    "data": [
      {
        "actions": [
          {
            "action_type": "comment",
            "value": "12"
          },
          {
            "action_type": "like",
            "value": "2"
          },
          {
            "action_type": "post",
            "value": "3"
          },
          {
            "action_type": "post_reaction",
            "value": "29"
          },
          {
            "action_type": "video_view",
            "value": "558"
          },
          {
            "action_type": "page_engagement",
            "value": "604"
          },
          {
            "action_type": "post_engagement",
            "value": "602"
          }
        ],
        "date_start": "2017-08-14",
        "date_stop": "2017-08-20"
      }
    ],
    "paging": {
      "cursors": {
        "before": "xxx",
        "after": "xxx"
      }
    }
  }
}

The effective_object_story_id (so, post_id) is 456000000_789000000.

You can then query the comments edge of the post adding summary=true as a parameter. This endpoint is public for common posts (however, it won't work for non public posts)

/456000000_789000000/comments?summary=true

Which will respond with an object like

{
  "data": [
     <LOTS OF COMMENTS HERE>
  ],
  "paging": {
    <PAGING LINKS>
  },
  "summary": {
    "order": "chronological",
    "total_count": 50,
    "can_comment": true
  }
}

This means the post has had 50 comments, of which 12 were made through a paid action.

ffflabs
  • 17,166
  • 5
  • 51
  • 77
  • 1
    Thank you so much for the detail answer. We can simply use this syntax to get adset comment: ...adset_id/insights?fields=actions. – lamxung55 Aug 19 '17 at 15:02
  • 1
    You might be right, I will check it out tomorrow. Last time I tried the actions breakdown was misleading and didn't match the value on the page dashboard. When building a report, one has to make sure that metrics are consistent, and you often need to dig through the metrics to find out when it is a valid result vs a result that might be counting duplicate people, or comments in a story that is a share of your post. – ffflabs Aug 20 '17 at 16:26
  • 1
    @lamxung55 I stand corrected. With your suggestion you can, actually, retrieve paid comments which is different from total post comments. – ffflabs Aug 21 '17 at 12:36
  • Yes you, I want to get comments which belong to my ads campaign (not total comment), this is a important factor of the campaign's efffective – lamxung55 Aug 22 '17 at 01:44
  • One more problem, all insight datas we get via graph are not synchronized with facebook ads manager (FB backend dashboard). Delayed about 6h than FB ads manager. How can we get realtime data – lamxung55 Aug 22 '17 at 01:59
  • @lamxung55 I doubt that can be done, mate. Querying ads stats specifying a timespan (period parameter) is described as `from the starting midnight of the "since" parameter to the ending midnight of the "until" parameter`. If your "until" is the current day I'm not sure how much delay it has in comparison to the Ads Manager. – ffflabs Aug 22 '17 at 10:52
0

We can simply use this syntax to get adset comment: ...adset_id/insights?fields=actions. Another ads stuffs are the same

lamxung55
  • 61
  • 1
  • 7