Metrik visibilitas kueri dan traffic tidak valid

Ringkasan

Petunjuk di bawah memberikan contoh cara membuat 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 YouTube Reserve.

Perhatikan bahwa metrik tampilan tampilan TrueView yang diakreditasi MRC memerlukan penggunaan ADH API, karena tidak ada kueri template terkait. Selain itu, metrik penayangan TrueView tidak boleh disamakan dengan metrik visibilitas.

Pilih pintu pembelian yang ingin Anda buat kueri metrik visibilitasnya:

Mengkueri metrik visibilitas menggunakan UI

Kueri visibilitas dengan template memberikan 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 yang diakreditasi 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, pastikan Anda memilih YouTube Reserve sebagai pintu pembelian dan Video Viewability sebagai template kueri.
  2. Klik tombol Run di samping Use template.

Membuat kueri metrik visibilitas dan traffic yang 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 diterapkan dan metrik Anda terakreditasi 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 YouTube Reserve kampanye Anda:

  • File rahasia klien
  • ID Pelanggan
  • Kunci API
  • Order IDs
  • Zona waktu

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))

Menghitung metrik visibilitas setelah dikurangi traffic tidak valid umum

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

  • Total Tayangan Iklan (Nilai Bersih GIVT): Total Tayangan Iklan - Tayangan Iklan Tidak Valid Umum
  • Tayangan Iklan yang Dapat Dilihat (Nilai Bersih GIVT): Tayangan Iklan yang Dapat Dilihat + Tayangan Iklan yang Dapat Dilihat Tidak Valid - Tayangan Iklan yang Dapat Dilihat GIVT
  • Tayangan Iklan Terukur (Nilai Bersih GIVT): Tayangan Iklan Terukur + Tayangan Iklan Terukur Tidak Valid - Tayangan Iklan Terukur GIVT
  • Tayangan Valid (Nilai Bersih GIVT): Tayangan Valid + Tayangan Valid yang Tidak Valid - Tayangan Valid GIVT
  • Tayangan Iklan Tidak Terlihat (Nilai Bersih GIVT) : Tayangan Iklan Terukur (Nilai Bersih GIVT) - Tayangan Iklan Terlihat (Nilai Bersih GIVT)
  • Tayangan Iklan yang Tidak Dapat Diukur (Nilai Bersih GIVT): Tayangan Iklan yang Memenuhi Syarat (Nilai Bersih GIVT) - Tayangan Iklan yang Dapat Diukur (Nilai Bersih GIVT)
  • % Tayangan Terukur (Nilai Bersih GIVT): Tayangan Terukur (Nilai Bersih GIVT) / Tayangan Valid (Nilai Bersih GIVT)
  • % Tayangan Iklan yang Dapat Dilihat (Nilai Bersih GIVT): Tayangan Iklan yang Dapat Dilihat (Nilai Bersih GIVT) / Tayangan Iklan yang Dapat Diukur (Nilai Bersih GIVT)