查询可见度和无效流量指标

概览

以下说明举例展示了如何使用 API 查询有效的可见流量及无效流量。这些指标仅适用于使用 Google Ads 和 Display & Video 360 购买的广告资源。

请注意,已获 MRC 认证的 TrueView 观看次数指标需要使用 ADH API,因为没有相关的模板化查询。此外,请勿将 TrueView 观看次数指标与可见度指标相混淆。

请选择要查询可见度指标的购买渠道:

通过界面查询可见度指标

模板化可见度查询提供已获 MRC 认证的指标。

MRC 认证结果分为两种(已获认证或未获认证),且适用于整个结果表。您必须通过模板运行查询,而不进行修改,并且在差异检查模式下运行,指标才能获得 MRC 认证。广告数据中心的 MRC 认证不适用于在噪声模式下运行的查询。

如要通过模板运行已获 MRC 认证的查询,请执行以下操作:

  1. 按照有关如何创建查询的说明进行操作,确保选择 Google Ads 作为购买渠道,同时选择按设备类型划分的视频广告可见度作为查询模板。
  2. 点击使用模板旁边的运行按钮。

通过 API 查询无效流量和可见度指标

您可以通过 ADH API 使用 generateIvtReport 和 startAnalysis 端点来检索无效流量和可见度指标。对于无效流量,您必须通过 generateIvtReport 检索指标,才能应用 adh-mrc-accredited 标签,您的指标也才能获得 MRC 认证。同样,必须通过 ADH API 使用下方指定的全局查询检索可见度指标,以获得 MRC 认证。本部分介绍了如何使用 Python 客户端库向此端点发送请求。

按照 API 快速入门中的设置和授权/身份验证说明进行操作。

将以下字段替换为与您的账号相关的信息后,您可以运行下方的查询来检索您的 Google Ads 广告系列的无效流量报告:

  • 客户端密钥文件
  • 客户 ID
  • API 密钥
  • Campaign IDs
  • 时区

示例代码

无效流量

import json
import os.path
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build

# If modifying these scopes, delete the file `token.json`.
SCOPES = ['https://www.googleapis.com/auth/adsdatahub']
TOKEN_FILE = 'token.json'

creds = None

# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists(TOKEN_FILE):
    creds = Credentials.from_authorized_user_file(TOKEN_FILE, SCOPES)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
    if creds and creds.expired and creds.refresh_token:
        creds.refresh(Request())
    else:
        flow = InstalledAppFlow.from_client_secrets_file(
            'YOUR_CLIENT_SECRETS.json', SCOPES)
        creds = flow.run_local_server(port=0)
    # Save the credentials for the next run.
    with open(TOKEN_FILE, 'w') as token:
        token.write(creds.to_json())

service = build('adsdatahub', 'v1', credentials=creds,
                developerKey='YOUR_API_KEY', static_discovery=False)

body = {
    'ads_data_customer_id': YOUR_CUSTOMER_ID,
    'start_date': {
        'year': 2019,
        'month': 12,
        'day': 15
    },
    'end_date': {
        'year': 2019,
        'month': 12,
        'day': 20
    },
    'time_zone': 'YOUR_TIMEZONE',
    # Optional. Defaults to 'DAY' (one set of rows per day). Use
    # 'ENTIRE_DATE_RANGE' for a single set of rows covering the whole range.
    'date_dimension_granularity': 'DAY',
    'google_ads_dimensions': {
        'campaign_ids': [YOUR_CAMPAIGN_IDS],
        'metric_type': 'METRIC_TYPE_IMPRESSION'
    },
    'dest_table': 'YOUR_DESTINATION_TABLE'
}

resp = service.customers().generateIvtReport(
    name='customers/YOUR_CUSTOMER_ID', body=body).execute()
print(json.dumps(resp))

可见度指标

import json
import os.path
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build

# If modifying these scopes, delete the file `token.json`.
SCOPES = ['https://www.googleapis.com/auth/adsdatahub']
TOKEN_FILE = 'token.json'

creds = None

# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists(TOKEN_FILE):
    creds = Credentials.from_authorized_user_file(TOKEN_FILE, SCOPES)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
    if creds and creds.expired and creds.refresh_token:
        creds.refresh(Request())
    else:
        flow = InstalledAppFlow.from_client_secrets_file(
            'YOUR_CLIENT_SECRETS.json', SCOPES)
        creds = flow.run_local_server(port=0)
    # Save the credentials for the next run.
    with open(TOKEN_FILE, 'w') as token:
        token.write(creds.to_json())

service = build('adsdatahub', 'v1', credentials=creds,
                developerKey='YOUR_API_KEY', static_discovery=False)

name = 'customers/global/analysisQueries/f41320e7296d49158e572aba662f35b1'
body = {
  'spec': {
    'ads_data_customer_id': YOUR_CUSTOMER_ID,
    'start_date': {
      'year': 2019,
      'month': 12,
      'day': 15
    },
    'end_date': {
      'year': 2019,
      'month': 12,
      'day': 20
    },
    'time_zone': 'YOUR_TIMEZONE',
    'parameter_values': {
      'campaign_ids': {
        'array_value': {
          'values': [
            {
              'value': 'YOUR_CAMPAIGN_ID'
            },
          ]
        }
      }
    }
  },
  'dest_table': 'YOUR_DESTINATION_TABLE',
  'customer_id': YOUR_CUSTOMER_ID
}

resp = service.customers().analysisQueries().start(name=name,body=body).execute()
print(json.dumps(resp))

计算可见度指标(不含常规无效流量)

使用以下公式计算不含常规无效流量 (GIVT) 的已获 MRC 认证的可见度指标:

  • 总展示次数(不含常规无效流量):总展示次数 - 常规无效展示次数
  • 可见的展示次数(不含常规无效流量):可见的展示次数 + 无效的可见展示次数 - 常规无效的可见展示次数
  • 可衡量的展示次数(不含常规无效流量):可衡量的展示次数 + 无效的可衡量展示次数 - 常规无效的可衡量展示次数
  • 符合条件的展示次数(不含常规无效流量):符合条件的展示次数 + 无效的符合条件展示次数 - 常规无效的符合条件展示次数
  • 不可见的展示次数(不含常规无效流量):可衡量的展示次数(不含常规无效流量)- 可见的展示次数(不含常规无效流量)
  • 不可衡量的展示次数(不含常规无效流量):符合条件的展示次数(不含常规无效流量)- 可衡量的展示次数(不含常规无效流量)
  • 可衡量的展示次数(不含常规无效流量)所占百分比:可衡量的展示次数(不含常规无效流量)/符合条件的展示次数(不含常规无效流量)
  • 可见的展示次数(不含常规无效流量)所占百分比:可见的展示次数(不含常规无效流量)/可衡量的展示次数(不含常规无效流量)