Visibilitas kueri dan metrik traffic tidak valid

Ringkasan

Petunjuk di bawah memberikan contoh cara mengajukan kueri traffic visibilitas yang valid dan traffic tidak valid menggunakan API. Metrik ini terbatas pada inventaris yang dibeli menggunakan Google Ads, Display & Video 360, dan reservasi YouTube.

Perhatikan bahwa metrik tampilan tampilan TrueView yang terakreditasi MRC mengharuskan penggunaan ADH API, karena tidak ada kueri dengan template terkait. Selain itu, metrik penayangan TrueView tidak sama dengan metrik visibilitas.

Pilih pintu pembelian yang metrik visibilitasnya ingin Anda kueri:

Membuat kueri metrik visibilitas menggunakan UI

Kueri visibilitas dengan template menyediakan metrik yang diakreditasi MRC.

Akreditasi MRC bersifat biner—hasil Anda dapat diakreditasi atau tidak—dan berlaku untuk seluruh tabel hasil Anda. Di BigQuery, label adh-mrc-accredited diterapkan ke semua hasil terakreditasi MRC. Anda harus menjalankan kueri melalui template agar metrik Anda terakreditasi MRC.

Untuk menjalankan kueri terakreditasi MRC melalui template:

  1. Ikuti petunjuk tentang cara membuat kueri, dan pastikan Anda memilih YouTube Reserve sebagai pintu pembelian dan Visibilitas Video sebagai template kueri.
  2. Klik tombol Run di sebelah Use template.

Mengkueri metrik visibilitas dan traffic tidak valid menggunakan API

Metrik traffic dan visibilitas yang tidak valid dapat diambil dari ADH API menggunakan endpoint generateIvtReport dan startAnalysis. Untuk traffic tidak valid, metrik Anda harus diambil melalui generateIvtReport agar label adh-mrc-accredited dapat diterapkan dan metrik Anda diakreditasi MRC. Demikian pula, kueri global yang ditentukan di bawah harus digunakan untuk metrik visibilitas melalui ADH API untuk akreditasi MRC. Bagian ini membahas cara mengirim permintaan ke endpoint ini menggunakan library klien Python.

Ikuti petunjuk penyiapan dan otorisasi/autentikasi di panduan memulai API.

Setelah mengganti kolom berikut dengan informasi yang relevan dengan akun Anda, Anda dapat menjalankan kueri di bawah untuk mengambil laporan traffic tidak valid untuk kampanye YouTube Reserve Anda:

  • File rahasia klien
  • ID Pelanggan
  • Kunci API
  • Order IDs
  • Timezone

Kode contoh

Traffic tidak valid

from __future__ import print_function
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',
                discoveryServiceUrl='https://adsdatahub.googleapis.com/$discovery/rest?version=v1&labels=')

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',
    'yt_reserve_dimensions': {
        'order_ids': [YOUR_ORDER_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))

Metrik visibilitas

from __future__ import print_function
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',
                discoveryServiceUrl='https://adsdatahub.googleapis.com/$discovery/rest?version=v1&labels=')

name = 'customers/global/analysisQueries/ad88e8562a8f4baa9c8522945fe95522'
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': {
      'line_item_ids': {
        'array_value': {
          'values': [
            {
              'value': 'YOUR_LINE_ITEM_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))

Hitung metrik visibilitas bersih dari traffic tidak valid umum

Gunakan formula berikut untuk mendapatkan metrik visibilitas yang terakreditasi MRC setelah traffic tidak valid umum (GIVT):

  • Total Tayangan (Bersih GIVT): Total Tayangan - Tayangan Tidak Valid Umum
  • Tayangan Terlihat (Bersih GIVT): Tayangan Terlihat + Tayangan Terlihat Tidak Valid - Tayangan Terlihat GIVT
  • Tayangan Terukur (Bersih GIVT): Tayangan Terukur + Tayangan Terukur Tidak Valid - Tayangan Terukur GIVT
  • Tayangan Valid (Bersih GIVT): Tayangan Valid + Tayangan Valid Tidak Valid - Tayangan Valid GIVT
  • Tayangan Iklan Tidak Terlihat (Bersih dari GIVT) : Tayangan Terukur (Bersih GIVT) - Tayangan Terlihat (Bersih dari GIVT)
  • Tayangan Tidak Terukur (Bersih GIVT): Tayangan Valid (Bersih GIVT) - Tayangan Terukur (Bersih GIVT)
  • % Tayangan Terukur (Bersih GIVT): Tayangan Terukur (Bersih GIVT) / Tayangan Layak (Bersih GIVT)
  • % Tayangan Terlihat (Bersih GIVT): Tayangan Terlihat (Bersih GIVT) / Tayangan Terukur (Bersih GIVT)