How to further filter Facebook Graph API query on Graph API Explorer for my ad account?

戏子无情 提交于 2021-02-07 08:19:40

问题


I'm trying to get the ad spend and mobile app installs for my app using the Facebook Graph API v2.11 for marketing. In the Graph API Explorer, when I try

/act_<my account>/campaigns?fields=insights{actions,spend}&time_range={'since':'2017-07-07','until':'2017-12-12'}

In the output, under "insights", I get an object of this type:

    "data": [
      {
        "actions": [             
          {
            "action_type": "comment",
            "value": "3"
          },
          {
            "action_type": "like",
            "value": "33"
          },
          {
            "action_type": "link_click",
            "value": "1531"
          },
          {
            "action_type": "mobile_app_install",
            "value": "1049"
          }
        ],
        "spend": "8621.03",
        "date_start": "2017-10-28",
        "date_stop": "2017-11-26"
      }
    ]

If I want it to fetch only the actions where action type is "mobile_app_install", how can I further filter my query?


回答1:


There is possible to filter that on Facebook side just call it like that:

/act_<yourAdAccount>/insights
  ?level=campaign
  &fields=actions,spend
  &time_increment=all_days
  &time_range={'since':'2017-07-07','until':'2017-12-12'}
  &filtering=[{field: "action_type",operator:"IN", value: ['mobile_app_install']}]
  &use_account_attribution_setting=true



回答2:


I have gone through the documentation as well as the adsinsights.py file on github but I cannot find a way to limit the number of action_types returned. You will simply have to do the filtering after you have retrieved the data from the api.

https://developers.facebook.com/docs/marketing-api/insights/parameters

https://github.com/facebook/facebook-python-ads-sdk/blob/master/facebookads/adobjects/adsinsights.py



来源:https://stackoverflow.com/questions/47508658/how-to-further-filter-facebook-graph-api-query-on-graph-api-explorer-for-my-ad-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!