อัปโหลดรหัสโฆษณาไปยังรายการผู้ใช้

คุณใช้ API เครื่องมืออัปโหลดเป็นกลุ่มเพื่อเพิ่มและนำรหัสโฆษณาออกจากรายชื่อผู้ใช้ของ Authorized Buyers เพื่อการกำหนดเป้าหมายได้ คุณไม่สามารถใช้ API เครื่องมืออัปโหลดเป็นกลุ่มของ Authorized Buyers เพื่อแก้ไขรายการกลุ่มเป้าหมายของ Display & Video 360

ต่อไปนี้เป็นตัวอย่าง URL ของ API เครื่องมืออัปโหลดเป็นกลุ่ม HTTPS

https://cm.g.doubleclick.net/upload?nid={GoogleNetworkId}

ปลายทางจะยอมรับคำขอ HTTPS POST

ค่าของ GoogleNetworkId ควรเป็นรหัสเครือข่ายการจับคู่คุกกี้ (NID) ซึ่งระบุบัญชีสําหรับเครื่องมืออัปโหลดหลายรายการพร้อมกันและการจับคู่คุกกี้โดยไม่ซ้ำกัน

เพย์โหลดของคำขอ HTTPS POST คือบัฟเฟอร์โปรโตคอลที่เข้ารหัสซึ่งระบุรายการที่จะแก้ไข ดูสคีมาสำหรับบริการเครื่องมืออัปโหลดเป็นกลุ่มใน cookie-bulk-upload-proto.txt เพย์โหลดของแต่ละคำขอจะจำกัดอยู่ที่ 100 KB

หากต้องการดูข้อมูลเพิ่มเติมเกี่ยวกับวิธีคอมไพล์และใช้ cookie-bulk-upload.proto เพื่อเรียงลำดับและแยกวิเคราะห์ข้อความ โปรดดูบทแนะนำสำหรับภาษาที่ต้องการ

คุณสามารถอัปโหลดตัวระบุประเภทต่อไปนี้

  • รหัสผู้ใช้ Google
  • รหัสที่พาร์ทเนอร์ระบุ
  • IDFA ของ iOS
  • รหัสโฆษณา Android
  • รหัส Roku
  • รหัส Fire TV ของ Amazon
  • Xbox หรือ Microsoft ID

อัปโหลดรหัสผู้ใช้ Google

รหัสผู้ใช้ Google คือรหัสที่เข้ารหัสจากโดเมน doubleclick.net

วิธีอัปโหลดรหัสผู้ใช้ Google มีดังนี้

  1. ตั้งค่าการจับคู่คุกกี้กับ Google และโฮสต์ตารางการจับคู่
  2. ใช้ตารางการจับคู่เพื่อแปลงรหัสผู้ใช้เป็นรหัสผู้ใช้ Google
  3. อัปโหลดรหัสผู้ใช้ Google ไปยังรายชื่อผู้ใช้

ตัวอย่างเช่น หากคุณได้รับรายการต่อไปนี้ระหว่างการจับคู่คุกกี้

https://ad.network.com/pixel?google_gid=CAESEHIV8HXNp0pFdHgi2rElMfk&google_cver=1

พารามิเตอร์ google_gid คือรหัสผู้ใช้ Google ที่เข้ารหัส

หากต้องการเพิ่มลงในรายการผู้ใช้ ให้คัดลอกไปยังเนื้อความ UpdateUsersDataRequest:

ops {
  user_id: "CAESEHIV8HXNp0pFdHgi2rElMfk"
  user_list_id: 111
  delete: false
  user_id_type: GOOGLE_USER_ID
}

อัปโหลดรหัสที่พาร์ทเนอร์ระบุ

รหัสที่ได้จากพาร์ทเนอร์คือรหัสที่อยู่ภายใต้โดเมนของพาร์ทเนอร์เอง วิธีอัปโหลดรหัสที่พาร์ทเนอร์ระบุมีดังนี้

  1. ตั้งค่าการจับคู่คุกกี้กับ Google และอนุญาตให้ Google โฮสต์ตารางการจับคู่ของคุณ

  2. อัปโหลดรหัสที่ได้จากพาร์ทเนอร์ไปยังรายชื่อผู้ใช้

    เช่น หากมีรหัสผู้ใช้สำหรับโดเมนที่ตั้งค่าเป็น 123456 คุณจะป้อนข้อมูลในตารางการจับคู่ที่โฮสต์ไว้ของ Google ได้ด้วยการจับคู่คุกกี้ แท็กการจับคู่ควรมีรหัสเวอร์ชันที่เข้ารหัสฐาน 64 ของเวอร์ชันเว็บซึ่งกำหนดให้กับพารามิเตอร์ google_hm ดังตัวอย่างต่อไปนี้

    https://cm.g.doubleclick.net/pixel?google_nid=cookie-monster&google_hm=MTIzNDU2&google_cm
    
  3. จากนั้น คุณจะอัปโหลดรหัสที่พาร์ทเนอร์ระบุไปยังรายชื่อผู้ใช้ได้ด้วย UpdateUsersDataRequest:

    ops {
     user_id: "123456"
     user_list_id: 123
     delete: false
     user_id_type: PARTNER_PROVIDED_ID
    }
    
  4. จากนั้น Google จะแปลรายชื่อผู้ใช้จากรหัสที่ได้จากพาร์ทเนอร์เป็นรหัสผู้ใช้ Google และเพิ่มรหัสดังกล่าวลงในรายการผู้ใช้

อัปโหลดรหัสโฆษณาของ IDFA หรือ Android

หรือจะอัปโหลดรหัสอุปกรณ์ก็ได้เช่นกัน

  1. อัปโหลดรหัสอุปกรณ์ด้วย UpdateUsersDataRequest:

    ops {
     user_id: "2024D65F-EBBD-11FF-23AB-823FC255913A"
     user_list_id: 111
     delete: false
     user_id_type: IDFA
    }
    
  2. จากนั้น Google จะแปลรายชื่อผู้ใช้จากรหัสอุปกรณ์เป็นรหัสผู้ใช้ Google แล้วเพิ่มรหัสลงในรายการผู้ใช้

ขั้นตอนการทำงาน

ตัวอย่างคำขอและการตอบกลับของเครื่องมืออัปโหลดจำนวนมากทั้งหมดเขียนไว้ในรูปแบบข้อความ โดยคุณจะต้องส่งข้อความ Protocol Buffer แบบอนุกรมไปยังปลายทาง Bulk Uploader API

เช่น หากต้องการอัปโหลด IDFA และรหัสที่พาร์ทเนอร์ระบุไปยังรายชื่อผู้ใช้ 123 ให้สร้าง UpdateUsersDataRequest โดยทำดังนี้

ops {
  user_id: "2024D65F-EBBD-11FF-23AB-823FC255913A"
  user_list_id: 123
  delete: false
  user_id_type: IDFA
}
ops {
  user_id: "1234567"
  user_list_id: 123
  delete: false
  user_id_type: PARTNER_PROVIDED_ID
}
# See warning before use. Requires affirmative end-user consent.
process_consent: true

จากนั้นส่งคำขอ HTTPS POST ที่มีข้อความ UpdateUsersDataRequest ที่เรียงลำดับเป็นเพย์โหลด

หากการดำเนินการทั้งหมดสำเร็จ คุณจะได้รับ UpdateUsersDataResponse ต่อไปนี้

status: NO_ERROR

หากการดำเนินการบางส่วนสำเร็จ การตอบกลับจะมี UpdateUsersDataResponse พร้อมข้อผิดพลาดสำหรับการดำเนินการที่ล้มเหลวแต่ละรายการ

status: PARTIAL_SUCCESS
errors {
  user_id: "1234567"
  error_code: UNKNOWN_ID
  user_id_type: PARTNER_PROVIDED_ID
}

หากการดำเนินการไม่สำเร็จ การตอบกลับจะมี UpdateUsersDataResponse ที่มี status ซึ่งตั้งค่าเป็น BAD_COOKIE

status: BAD_COOKIE

ตัวอย่าง

นี่คือตัวอย่างสคริปต์ Python ที่สาธิตวิธีใช้ไลบรารีที่ cookie-bulk-upload.promo สร้างไว้เพื่อสร้างรายชื่อผู้ใช้ด้วยรหัสที่กำหนดโดยใช้บริการตัวอัปโหลดหลายรายการพร้อมกัน

  #!/usr/bin/python
#
# Copyright 2023 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""A sample demonstrating usage of the Authorized Buyers Bulk Upload service.

Successfully running this example will add the provided ID to the given user
list. To learn more about the bulk uploader service, see:
https://developers.google.com/authorized-buyers/rtb/bulk-uploader
"""


import argparse

import gen.cookie_bulk_upload_pb2

import requests


BULK_UPLOAD_ENDPOINT_TEMPLATE = 'https://cm.g.doubleclick.net/upload?nid=%s'


def main(account_nid, user_list_id, user_id, user_id_type):
    # Build the bulk upload request.
    update_request = gen.cookie_bulk_upload_pb2.UpdateUsersDataRequest()
    update_request.send_notifications = True

    ops = update_request.ops
    op = ops.add()
    op.user_list_id = user_list_id
    op.user_id = user_id
    op.user_id_type = user_id_type

    user_id_type_value = gen.cookie_bulk_upload_pb2.UserIdType.Name(
        user_id_type)

    print(f'For NID "{account_nid}", adding user ID "{user_id}" of type '
          f'"{user_id_type_value}" to user list ID "{user_list_id}"')

    # Execute the bulk upload request.
    response = requests.post(BULK_UPLOAD_ENDPOINT_TEMPLATE % account_nid,
                             data=update_request.SerializeToString())

    # Parse and display the response.
    update_response = gen.cookie_bulk_upload_pb2.UpdateUsersDataResponse()
    update_response.ParseFromString(response.content)

    print('Operation completed with the following:')
    print(f'\tHTTP Status code: {response.status_code}')
    status_value = gen.cookie_bulk_upload_pb2.ErrorCode.Name(
        update_response.status)
    print(f'\tUpdateUsersDataResponse.status: {status_value}')
    print(f'\tUpdateUsersDataResponse.errors: {update_response.errors}')
    print('\tUpdateUsersDataResponse.notifications: '
          f'{update_response.notifications}')
    n_status_value = gen.cookie_bulk_upload_pb2.NotificationStatus.Name(
        update_response.notification_status)
    print(f'\tUpdateUsersDataResponse.notification_status: {n_status_value}')


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description=('A sample demonstrating usage of the Authorized Buyers '
                     'bulk uploader service.'))
    parser.add_argument('-n', '--account_nid',
                        required=True, help='The Account NID.')
    parser.add_argument('-u', '--user_id',
                        required=True, help='The User ID to be added.')
    parser.add_argument('-l', '--user_list_id', type=int, required=True,
                        help='The user list that the ID is being added to.')
    parser.add_argument('-t', '--user_id_type', type=int, required=True,
                        help=('The type of user ID being added. See '
                              '"UserIdType" enum for more details.'))
    args = parser.parse_args()

    main(args.account_nid, args.user_list_id, args.user_id, args.user_id_type)


พาร์ทเนอร์ที่ใช้ API การอัปโหลดจำนวนมากต้องระบุว่าตนมีพื้นฐานทางกฎหมายที่เหมาะสมในการแชร์ข้อมูลผู้ใช้กับ Google เพื่อวัตถุประสงค์ในการอัปโหลดจำนวนมากโดยใช้พารามิเตอร์ process_consent ข้อกำหนดนี้ใช้กับคำขอ การอัปโหลดจำนวนมากทั้งหมด

สำหรับข้อมูลผู้ใช้ที่ต้องได้รับความยินยอมจากผู้ใช้ปลายทางตามที่นโยบายความยินยอมของผู้ใช้ EU ของ Google กำหนด (ดู https://www.google.com/about/company/user-consent-policy/) หรือตามกฎหมายท้องถิ่นอื่นๆ พาร์ทเนอร์จะต้องได้รับความยินยอมจากผู้ใช้ปลายทางและระบุความยินยอมที่รวบรวมโดยการตั้งค่า process_consent=True

สำหรับข้อมูลผู้ใช้ที่ไม่ขึ้นอยู่กับข้อกำหนดความยินยอมของผู้ใช้ปลายทาง พาร์ทเนอร์จะต้องระบุว่าการตั้งค่า process_consent=True ไม่จำเป็นต้องได้รับความยินยอม

คำขอที่ไม่มี process_consent จะถูกกรองออกและแสดงข้อผิดพลาดต่อไปนี้

status: MISSING_CONSENT_WILL_BE_DROPPED

คำขอที่ตั้งค่า process_consent เป็น false จะถูกกรองและแสดงข้อผิดพลาดต่อไปนี้

status: MISSING_CONSENT