facebook api之Ads Insights API
The Ads Insights API
provides API access for reporting and analytics purposes.
When exclusively using the Ad Insights API, request the ads_read permission.
1. Marketing API Quickstart
2. Example Query: Campaign Statistics
3. All References
# Next Steps
1. Marketing API Quickstart
To get started with the Marketing API, start by creating an app.
Once created, you can add Marketing API as a product and go through the Quickstart experience within your app dashboard.
Marketing API Quickstart simplifies using the Marketing API by generating sample code for you.
It is a step-by-step on-boarding flow that helps you use ad management and insights tools built on Facebook's Marketing API.
You can start getting insights from your Facebook Pixel or App Ads SDKs by clicking the Create Ad reports below.

#To get the statistics of a campaign's last 7 day performance run the following query:
curl -G \
-d "date_preset=last_7_days" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<AD_CAMPAIGN_ID>/insights"
To learn more about how to query statistics, see the ad insights edge documentation.
3. All References
The Ads Insights API has the following references that we strongly recommend to read:
Insights
This insights edge provides a single, consistent interface to retrieve an ad's statistics.
- Parameters - Parameters available on this endpoint.
- Fields - Options for in the
fieldsparameter for this endpoint. - Breakdowns - Group results from API calls
- Action Breakdowns - Understanding the response from action breakdowns.
- Async Jobs - For requests with large results, use asynchronous jobs
- Limits and Best Practices - Explains Insights API call limits, filtering and best practices.
- Metrics Names and API Fields - Metrics Names in Facebook Ads tools with corresponding API fields.
Making A Call
The Insights API is available as an edge on any ads object.
| API Method |
|---|
|
|
|
|
|
|
|
|
#You can request specific fields with a comma-separated list in the fields parameters:
curl -G \
-d "fields=impressions" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<AD_OBJECT_ID>/insights"
Levels
Aggregate results at a defined object level. This automatically deduplicates data.
# get a campaign's insights on ad level.
curl -G \
-d "level=ad" \
-d "fields=impressions,ad_id" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<CAMPAIGN_ID>/insights"
If you don't access to all the ad objects at the requested level, the insights call returns no data.
For example, while requesting insights with level as ad, if you don't have access to one or more ad objects under the ad account, this api call will return a permission error.
Attribution Windows
The conversion attribution window provides timeframes that define when we attribute an event to an ad on Facebook.
For background information, see Facebook Ads Help Center, How Attribution Reporting Works.
We measure the actions that occur when a conversion event occurs and look back in time 1-day, 7-days, and 28 days.
To view actions attributed to different attribution windows, make a request to /{ad-account-id}/insights.
If you do not provide action_attribution_windows we use 28d_click and 1d_view and provide it under 'value'.
#For example specify action_attribution_windows and 'value' is fixed at 28d_click and 1d_view attribution windows.
# Make a request to act_10151816772662695/insights?action_attribution_windows=['1d_click','1d_view']
Field Expansion
Request fields at the node level and by fields specified in field expansion:
curl -G \
-d "fields=insights{impressions}" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<AD_ID>"
Sorting
Sort results by providing the sort parameter with {fieldname}_descending or {fieldname}_ascending:
curl -G \
-d "sort=reach_descending" \
-d "level=ad" \
-d "fields=reach" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<ADSET_ID>/insights"
Ads Labels
Stats for all labels whose names are identical.
Aggregated into a single value at an ad object level.
curl -G \
-d "fields=id,name,insights{unique_clicks,cpm,total_actions}" \
-d "level=ad" \
-d 'filtering=[{"field":"ad.adlabels","operator":"ANY", "value":["Label Name"]}]' \
-d 'time_range={"since":"2015-03-01","until":"2015-03-31"}' \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<AD_OBJECT_ID>/insights"
Clicks Definition
To better understand the three click metrics that Facebook offers today, please read the definitions and usage of each below:
Link Clicks,
actions:link_click- The number of clicks on ad links to select destinations or experiences, on or off Facebook-owned properties. See Ads Help Center, Link ClicksClicks (All),
clicks- The metric counts multiple types of clicks on your ad, including certain types of interactions with the ad container, links to other destinations, and links to expanded ad experiences. See Ads Help Center, Clicks(All)
Deleted and Archived Objects
Ad units may be DELETED or ARCHIVED.
The stats of deleted or archived objects appear when you query their parents.
This means if you query impressions at the ad set level, results include impressions from all ads in the set it, regardless of whether the the ads are in a deleted or archived state.
See also, Storing and Retrieving Ad Objects Best Practice.
However if you query at a certain level, such as level=ad, objects that have been archived or deleted do not appear.
As the result, the total stats of the parent node may be greater than the stats of its children.
By default, ARCHIVED objects are not included in the response of the insights edge, such as act_<AD_ACCOUNT_id>/insights?level=ad.
You can get the stats of ARCHIVED objects from their parent nodes though, by providing an extra filteringparameter.
#To get the stats of all ARCHIVED ads in an ad account listed one by one:
curl -G \
-d "level=ad" \
-d "filtering=[{'field':'ad.effective_status','operator':'IN','value':['ARCHIVED']}]" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/insights/" #You can query insights on deleted objects if you have their IDs or by using the ad.effective_status filter. For example, if you have the ad set ID: curl -G \
-d "fields=id,name,status,insights{impressions}" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<ADSET_ID>" #In this example, we query with ad.effective_status:
POST https://graph.facebook.com/<VERSION>/act_ID/insights?access_token=token&appsecret_proof=proof&fields=ad_id,impressions&date_preset=lifetime&level=ad&filtering=[{"field":"ad.effective_status","operator":"IN","value":["DELETED"]}]
Troubleshooting
Timeouts
The most common issues causing failure at this endpoint are too many requests and time outs:
- On
/GETor synchronous requests, you can get out-of-memory or timeout errors. - On
/POSTor asynchronous requests, you can possibly get timeout errors. For asynchronous requests, it can take up to an hour to complete a request including retry attempts. For example if you make a query that tries to fetch large volume of data for many ad level objects.
Recommendations
- There is no explicit limit for when a query will fail. When it times out, try to break down the query into smaller queries by putting in filters like date range.
- Unique metrics are time consuming to compute. Try to query unique metrics in a separate call to improve performance of non-unique metrics.
Rate Limiting
The Facebook Insights API utilizes rate limiting to ensure an optimal reporting experience for all of our partners. For more information and suggestions, see our Insights API Limits & Best Practices.
facebook api之Ads Insights API的更多相关文章
- facebook api之Business Manager API
Business-scoped Users - The new user is tied to a particular business and has permissions scoped to ...
- API Monitor简介(API监控工具)
API Monitor是一个免费软件,可以让你监视和控制应用程序和服务,取得了API调用. 它是一个强大的工具,看到的应用程序和服务是如何工作的,或跟踪,你在自己的应用程序的问题. 64位支持 API ...
- Request Entity Too Large for Self Hosted ASP.Net Web API在Selfhost的api后台怎么解决Request Entity Too Large问题
Request Entity Too Large for Self Hosted ASP.Net Web API在Selfhost的api后台怎么解决Request Entity Too Large问 ...
- 使用 WSO2 API Manager 管理 Rest API
WSO2 API Manager 简介 随着软件工程的增多,越来越多的软件提供各种不同格式.不同定义的 Rest API 作为资源共享,而由于这些 API 资源的异构性,很难对其进行复用.WSO2 A ...
- Zookeeper C API 指南四(C API 概览)(转)
上一节<Zookeeper C API 指南三(回调函数)>重点讲了 Zookeeper C API 中各种回调函数的原型,本节将切入正题,正式讲解 Zookeeper C API.相信大 ...
- Atitit.一个cms有多少少扩展点,多少api wordpress cms有多少api。。扩展点
Atitit.一个cms有多少少扩展点,多少api wordpress cms有多少api..扩展点 1. Api分类 WordPress APIs1 1.1. 1 函数分类2 1.2. 函数api ...
- ASP.NET Web API与Rest web api(一)
HTTP is not just for serving up web pages. It is also a powerful platform for building APIs that exp ...
- ASP.NET Web API与Rest web api(一)
本文档内容大部分来源于:http://www.cnblogs.com/madyina/p/3381256.html HTTP is not just for serving up web pages. ...
- [Web API] 如何让 Web API 统一回传格式以及例外处理[转]
[Web API] 如何让 Web API 统一回传格式以及例外处理 前言 当我们在开发 Web API 时,一般的情况下每个 API 回传的数据型态或格式都不尽相同,如果你的项目从头到尾都是由你一个 ...
随机推荐
- 【Linux学习十】负载均衡带来tomcat的session不一致问题
环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 tomcat7 jdk7 session不一致是指web服务器(tom ...
- Visual Assist 10.9.2248 破解版(支持VS2017)
[1]下载安装包 下载地址:https://download.csdn.net/download/qq_20044811/10597708 [2]安装与破解方法 第一步:关闭VS所有打开窗体 第二步: ...
- AttributeError: module 'DBBase' has no attribute 'DBBase'
AttributeError: module 'DBBase' has no attribute 'DBBase' pycharm不会将当前文件目录自动加入自己的sourse_path.右键make_ ...
- 转:WCF传送二进制流数据基本实现步骤详解
来自:http://developer.51cto.com/art/201002/185444.htm WCF传送二进制流数据基本实现步骤详解 2010-02-26 16:10 佚名 CSDN W ...
- 转:[你必须知道的异步编程]C# 5.0 新特性——Async和Await使异步编程更简单
本专题概要: 引言 同步代码存在的问题 传统的异步编程改善程序的响应 C# 5.0 提供的async和await使异步编程更简单 async和await关键字剖析 小结 一.引言 在之前的C#基础知 ...
- java连接oracle数据库使用SERVICE NAME、SID以及TNSName不同写法
格式一: 使用ServiceName方式: jdbc:oracle:thin:@//<host>:<port>/<service_name> 例 jdbc:orac ...
- <转>jmeter(十)参数化
本博客转载自:http://www.cnblogs.com/imyalost/category/846346.html 个人感觉不错,对jmeter讲解非常详细,担心以后找不到了,所以转发出来,留着慢 ...
- Hadoop学习笔记之三:DataNode
DataNode对ClientDatanodeProtocol.InterDatanodeProtocol两个协议接口进行了实现,通过ipc::Server向Client.其它DN提供RPC服务(参见 ...
- 理解Sql Server 事务隔离层级(Transaction Isolation Level)
关于Sql Server 事务隔离级别,百度百科是这样描述的 隔离级别:一个事务必须与由其他事务进行的资源或数据更改相隔离的程度.隔离级别从允许的并发副作用(例如,脏读或虚拟读取)的角度进行描述. 隔 ...
- OpenStack平台上,windows云主机可以ping通百度但是无法打开网页,部分其它网页可以打开
问题描述: 在OpenStack平台上的64位Windows7虚拟机,可以ping通百度,但是却无法打开百度网页. 于是,笔者又对其它网址进行的测试,发现淘宝.京东.携程部分网页可以打开,而新浪等等网 ...