我需要在 Android 应用程序中跟踪来自 AdMob 的报告。我需要展示次数、点击次数、点击率、ecpm 和估计收入等信息。是否有某种支持这一点的api?
3 回答
AdMob API:https ://developers.google.com/admob/api
要求
curl -X POST https://admob.googleapis.com/v1/accounts/<your_publisher_id>/networkReport:generate \
-H "'Authorization: Bearer <oauth2_access_token>" \
-H "Content-Type: application/json" \
--data @- << EOF
{
"report_spec": {
"date_range": {
"start_date": {"year": 2020, "month": 4, "day": 2},
"end_date": {"year": 2020, "month": 4, "day": 2}
},
"dimensions": ["APP", "AD_UNIT"],
"metrics": ["AD_REQUESTS", "IMPRESSIONS", "ESTIMATED_EARNINGS"]
}
}
EOF
获取 Oauth2.0 访问令牌
使用 oauth2l
安装:https ://github.com/google/oauth2l
oauth2l header --json <path_to_secret_json> https://www.googleapis.com/auth/admob.report
path_to_secret_json - 来自谷歌云控制台上的凭证页面之一。
卷曲
将oauth2_client_id替换为您在“云项目凭据 - OAuth 2.0 客户端 ID”页面中拥有的那个。( https://console.developers.google.com/apis/credentials?project= )
https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadmob.report&response_type=code&client_id= &redirect_uri=urn%3Aietf%3Awg%3Aoauth% 3A2.0%3Aoob
- 以隐身浏览器模式打开此链接;
- 按照说明,接受 AdMob 发布者帐户的辅音屏幕;
- 复制代码,以下请求将需要它:
curl -L \
-d "client_id=<oauth2_client_id>" \
-d "client_secret=<oauth2_secret>" \
-d "grant_type=authorization_code" \
-d "code=<sign_in_code_from_the_previous_step>" \
-d "redirect_uri=urn:ietf:wg:oauth:2.0:oob" \
https://accounts.google.com/o/oauth2/token
oaut2_client_id和oauth2_secret可以在 OAuth 2.0 客户端 ID 页面上找到。
回复:
{
"access_token": "<access_token>",
"expires_in": 3600,
"refresh_token": "<refresh_token>",
"scope": "https://www.googleapis.com/auth/admob.report",
"token_type": "Bearer"
}
有关开发人员文档的更多详细信息:https ://developers.google.com/admob/api/v1/getting-started
不确定我是否正确理解您在“应用程序内跟踪报告”下的意思,但猜您可以使用 AdSense API 来做到这一点。
简单来说,每个应用程序都与一个 adunit ID 相关联,因此如果您想查看某个应用程序的统计信息,请查看: https ://developers.google.com/adsense/management/v1.3/reference/accounts /报告/生成
accountId = your Publisher ID (pub-XXXXXXX)
startDate and endDate = The interval of dates you want to check
dimension = AD_UNIT_ID
metric = EARNINGS
With this query you'll have the required info, separated by App.