【问题标题】:Receiving reports data in AdSense v2在 AdSense v2 中接收报告数据
【发布时间】:2021-08-31 11:56:10
【问题描述】:

虽然 migrating 来自旧版本,但我在提取报告时遇到了问题。

来自 v1.4 的相同报告在 v2 中不返回任何数据:

v1.4 报告抓取:

self.service.accounts().reports().generate(
                accountId=account_id, startDate=start_date.strftime(self.DATE_FORMAT),
                endDate=end_date.strftime(self.DATE_FORMAT),
                metric=metrics, dimension=dimensions).execute()

获取https://www.googleapis.com/adsense/v1.4/accounts/pub-***/reports?startDate=2021-06-13&metric=REACHED_AD_REQUESTS&metric=CLICKS&metric=EARNINGS&metric=VIEWED_IMPRESSIONS&metric=MATCHED_REACHED_AD_REQUESTS&endDate=2021-06-13&dimension=DATE&dimension=APP_NAME&dimension=APP_ID&dimension=APP_PLATFORM&dimension=BID_TYPE_CODE&dimension=PRODUCT_NAME&dimension=COUNTRY_NAME&dimension=AD_UNIT_CODE&dimension=AD_UNIT_NAME&dimension=AD_UNIT_SIZE_NAME&dimension=AD_UNIT_SIZE_CODE&dimension=REACHED_AD_REQUESTS&alt=json

回复:

{u'averages': ...,
 u'endDate': u'2021-06-13',
 u'headers': [{u'name': u'DATE', u'type': u'DIMENSION'},
  {u'name': u'APP_NAME', u'type': u'DIMENSION'},
  {u'name': u'APP_ID', u'type': u'DIMENSION'},
  {u'name': u'APP_PLATFORM', u'type': u'DIMENSION'},
  {u'name': u'BID_TYPE_CODE', u'type': u'DIMENSION'},
  {u'name': u'PRODUCT_NAME', u'type': u'DIMENSION'},
  {u'name': u'COUNTRY_NAME', u'type': u'DIMENSION'},
  {u'name': u'AD_UNIT_CODE', u'type': u'DIMENSION'},
  {u'name': u'AD_UNIT_NAME', u'type': u'DIMENSION'},
  {u'name': u'AD_UNIT_SIZE_NAME', u'type': u'DIMENSION'},
  {u'name': u'AD_UNIT_SIZE_CODE', u'type': u'DIMENSION'},
  {u'name': u'REACHED_AD_REQUESTS', u'type': u'METRIC_TALLY'},
  {u'name': u'CLICKS', u'type': u'METRIC_TALLY'},
  {u'currency': u'USD', u'name': u'EARNINGS', u'type': u'METRIC_CURRENCY'},
  {u'name': u'VIEWED_IMPRESSIONS', u'type': u'METRIC_TALLY'},
  {u'name': u'MATCHED_REACHED_AD_REQUESTS', u'type': u'METRIC_TALLY'}],
 u'kind': u'adsense#report',
 u'rows': ...
u'startDate': u'2021-06-13',
 u'totalMatchedRows': u'10069',
 u'totals': ...,
u'warnings': [u'Some of the requested ad clients do not support the requested combination of dimensions.',
  u'Some of the requested ad clients do not support the requested combination of dimensions.']}

v2 报告抓取:

self.service.accounts().reports().generate(
                account='accounts/' + account_id, dateRange="CUSTOM",
                startDate_year=start_date.year, startDate_month=start_date.month, startDate_day=start_date.day,
                endDate_year=end_date.year, endDate_month=end_date.month, endDate_day=end_date.day,
                metrics=metrics, dimensions=dimensions).execute()

获取https://adsense.googleapis.com/v2/accounts/pub-***/reports:generate?startDate.month=6&endDate.day=13&dimensions=DATE&dimensions=PRODUCT_NAME&dimensions=PLATFORM_TYPE_NAME&dimensions=BID_TYPE_CODE&dimensions=COUNTRY_NAME&dimensions=AD_UNIT_ID&dimensions=AD_UNIT_NAME&dimensions=AD_UNIT_SIZE_NAME&dimensions=AD_UNIT_SIZE_CODE&endDate.month=6&startDate.year=2021&startDate.day=13&metrics=AD_REQUESTS&metrics=CLICKS&metrics=TOTAL_EARNINGS&metrics=TOTAL_IMPRESSIONS&metrics=MATCHED_AD_REQUESTS&endDate.year=2021&alt=json&dateRange=CUSTOM

回复:

{u'endDate': {u'day': 13, u'month': 6, u'year': 2021},
 u'headers': [{u'name': u'DATE', u'type': u'DIMENSION'},
  {u'name': u'PRODUCT_NAME', u'type': u'DIMENSION'},
  {u'name': u'PLATFORM_TYPE_NAME', u'type': u'DIMENSION'},
  {u'name': u'BID_TYPE_CODE', u'type': u'DIMENSION'},
  {u'name': u'COUNTRY_NAME', u'type': u'DIMENSION'},
  {u'name': u'AD_UNIT_ID', u'type': u'DIMENSION'},
  {u'name': u'AD_UNIT_NAME', u'type': u'DIMENSION'},
  {u'name': u'AD_UNIT_SIZE_NAME', u'type': u'DIMENSION'},
  {u'name': u'AD_UNIT_SIZE_CODE', u'type': u'DIMENSION'},
  {u'name': u'AD_REQUESTS', u'type': u'METRIC_TALLY'},
  {u'name': u'CLICKS', u'type': u'METRIC_TALLY'},
  {u'currencyCode': u'USD',
   u'name': u'TOTAL_EARNINGS',
   u'type': u'METRIC_CURRENCY'},
  {u'name': u'TOTAL_IMPRESSIONS', u'type': u'METRIC_TALLY'},
  {u'name': u'MATCHED_AD_REQUESTS', u'type': u'METRIC_TALLY'}],
 u'startDate': {u'day': 13, u'month': 6, u'year': 2021},
 u'warnings': [u'Some of the requested dimensions (or their combination) do not apply to some of the ad clients used by this report.',
  u'Some of the requested metrics are not available for some of the ad clients used by this report.']}

还检查了python example,但一切都一样。

如果需要,将私下发送 account_id。

*为 AdSense 管理 API 使用 python 包(googleapiclient、oauth2client)。

谢谢

【问题讨论】:

    标签: report adsense adsense-api migrating


    【解决方案1】:

    这是 AdSense 帐户还是 AdMob 帐户?我注意到您在第一份报告中使用了一些“APP”维度。来自v2 release notes“报告”部分:“不再支持 AdMob 和 YouTube 媒体资源。”如果这是 AdMob 属性,您应该migrate to the AdMob API

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-31
      • 1970-01-01
      • 1970-01-01
      • 2014-08-11
      • 2015-10-26
      • 1970-01-01
      • 1970-01-01
      • 2022-07-22
      相关资源
      最近更新 更多