将广告 ID 上传到用户名单

您可以使用 Bulk Uploader API 向 Authorized Buyers 用户名单添加和移除广告 ID,以便用于定位。

以下是 HTTPS Bulk Uploader API 网址示例:

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

端点接受 HTTPS POST 请求。

GoogleNetworkId 的值应该是您的 Cookie 匹配网络 ID (NID),用于在批量上传工具和 Cookie 匹配中唯一标识您的账号。

HTTPS POST 请求的载荷是一个经过编码的协议缓冲区,用于描述要修改的列表。请参阅 cookie-bulk-upload-proto.txt 中的批量上传程序服务架构。每个请求的载荷上限为 100 KB

如需详细了解如何编译和使用 cookie-bulk-upload.proto 来序列化和解析消息,请参阅与您的首选语言对应的教程

您可以上传以下类型的标识符:

  • Google 用户 ID
  • 合作伙伴提供的 ID
  • iOS 广告标识符 (IDFA)
  • Android 广告 ID
  • Roku ID
  • Amazon Fire TV ID
  • Xbox 或 Microsoft ID

上传 Google 用户 ID

Google 用户 ID 是来自 doubleclick.net 网域的加密 ID。

上传 Google 用户 ID 的方法如下:

  1. 通过 Google 设置 Cookie 匹配并托管匹配表。
  2. 使用匹配表将用户 ID 转换为 Google 用户 ID。
  3. 将 Google 用户 ID 上传到用户列表。

例如,如果您在 Cookie 匹配期间收到以下内容:

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

google_gid 参数是加密的 Google 用户 ID。

如需将其添加到用户列表中,请将其复制到 UpdateUsersDataRequest 正文:

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

上传合作伙伴提供的 ID

合作伙伴提供的 ID 是合作伙伴自己的网域下的 ID。上传合作伙伴提供的 ID 的方法如下:

  1. 通过 Google 设置 Cookie 匹配,并允许 Google 托管您的匹配表。

  2. 将合作伙伴提供的 ID 上传到用户列表。

    例如,如果您将网域的用户 ID 设置为 123456,则可以使用 Cookie 匹配功能将其填充到 Google 的托管匹配表中。您的匹配标记应包含分配给 google_hm 参数的网络安全 base64 编码的 ID 版本,如下所示:

    https://cm.g.doubleclick.net/pixel?google_nid=cookie-monster&google_hm=MTIzNDU2&google_cm
    
  3. 然后,您可以使用 UpdateUsersDataRequest 将合作伙伴提供的 ID 上传到用户名单:

    ops {
     user_id: "123456"
     user_list_id: 123
     delete: false
     user_id_type: PARTNER_PROVIDED_ID
    }
    
  4. 然后,Google 会将用户列表从合作伙伴提供的 ID 转换为 Google 用户 ID,并将 ID 添加到您的用户列表中。

上传 IDFA 或 Android 广告 ID

您还可以上传设备 ID。

  1. 使用 UpdateUsersDataRequest 上传设备 ID:

    ops {
     user_id: "2024D65F-EBBD-11FF-23AB-823FC255913A"
     user_list_id: 111
     delete: false
     user_id_type: IDFA
    }
    
  2. 然后,Google 会将用户列表从设备 ID 转换为 Google 用户 ID,并将这些 ID 添加到您的用户列表中。

工作流

所有批量上传程序请求和响应示例都是以文本格式编写的。您必须将它们作为序列化 Protocol Buffer 消息发送到 Bulk Uploader API 端点。

例如,如需将 IDFA 和合作伙伴提供的 ID 上传到用户列表 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
}

如果所有操作均未成功,响应会包含 status 设置为 BAD_COOKIEUpdateUsersDataResponse

status: BAD_COOKIE

示例

这是一个 Python 脚本示例,演示了如何使用由 cookie-Bulk-upload.proto 生成的库,通过批量上传器服务使用指定 ID 填充用户列表:

  #!/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)


使用 Bulk Upload API 的合作伙伴必须表明自己有正当的法律依据,可以使用 process_consent 参数与 Google 共享用户数据以进行批量上传。此要求适用于所有批量上传请求。

对于需要按照 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