您可以使用上传的客户联系信息创建目标客户匹配受众群体 信息或移动设备 ID。Video 360 API。本页将介绍 创建初始目标客户匹配受众群体,并将新客户数据附加到 使用展示广告系列和Video 360 API。
准备用户数据
用于填充目标客户匹配受众群体的用户数据属于敏感数据,需要 必须做足准备
对敏感数据进行哈希处理
部分目标客户匹配受众群体是使用敏感的客户联系信息创建的 信息。展示广告与Video 360 要求使用 SHA256 算法。以下数据字段必须经过哈希处理 上传前:
- 名字
- 姓氏
- 电子邮件地址
- 电话号码
邮政编码和国家/地区代码在上传之前不应进行哈希处理。正在尝试 上传未经过哈希处理的客户数据会导致错误。
在对数据进行哈希处理之前,请确保满足以下条件:
- 必须移除名字、姓氏和电子邮件地址中的所有空格 值。
- 所有值都必须小写。
- 所有电话号码都必须采用 E.164 格式,并且 包含国家/地区呼叫代码。
设置用户意见征求
上传用户数据时,请使用所提供的consent
ContactInfoList
或
MobileDeviceIdList
对象,用于传递意见征求信号
用户授予的权限。
将 Consent
对象中的任一字段设置为
CONSENT_STATUS_DENIED
会导致错误。
系统会为在单个中添加的所有用户设置意见征求信号
firstAndThirdPartyAudiences.create
或
firstAndThirdPartyAudiences.editCustomerMatchMembers
请求。对于具有不同意见征求信号的用户,必须在
请求。
创建目标客户匹配受众群体
您可以使用
firstAndThirdPartyAudiences.create
方法。受众群体必须
必须声明为第一方受众群体
audienceType
/
CUSTOMER_MATCH_CONTACT_INFO
或
CUSTOMER_MATCH_DEVICE_ID
。目标客户匹配数据必须
使用并集字段中的相应字段提供
members
。
以下示例展示了如何创建新的联系信息、目标客户匹配 使用所提供的经过哈希处理、 电话号码:
Java
// Create Customer Match audience object. FirstAndThirdPartyAudience customerMatchAudience = new FirstAndThirdPartyAudience() .setDisplayName(display-name) .setFirstAndThirdPartyAudienceType( "FIRST_AND_THIRD_PARTY_AUDIENCE_TYPE_FIRST_PARTY" ) .setAudienceType("CUSTOMER_MATCH_CONTACT_INFO") .setMembershipDurationDays(10000L); // Build list of contact information objects. ContactInfoList contactInfoList = new ContactInfoList(); ArrayList<ContactInfo> contactInfos = new ArrayList<ContactInfo>(); for (String hashedPhoneNumber : list-of-hashed-phone-numbers) { ContactInfo contactInfo = new ContactInfo(); ArrayList<String> phoneNumberList = new ArrayList<String>(); phoneNumberList.add(hashedPhoneNumber); contactInfo.setHashedPhoneNumbers(phoneNumberList); contactInfos.add(contactInfo); } contactInfoList.setContactInfos(contactInfos); // Build consent object for passing consent if granted by the end user. Consent consent = new Consent() .setAdUserData(ad-user-data-consent) .setAdPersonalization(ad-personalization-consent); ContactInfoList.setConsent(consent); // Assign contact info list to Customer Match audience. customerMatchAudience.setContactInfoList(contactInfoList); // Create Customer Match audience. FirstAndThirdPartyAudience response = service .firstAndThirdPartyAudiences() .create(customerMatchAudience) .setAdvertiserId(advertiser-id) .execute(); // Display name of new audience. System.out.printf( "Customer Match audience %s was created.", response.getName() );
Python
# Build list of Contact Info objects contact_infos = [] for hashed_phone_number in list-of-hashed-phone-numbers: contact_infos.append({'hashedPhoneNumbers': [hashed_phone_number]}) # Create a Customer Match first- and third-party audience object. audience_obj = { 'displayName': display-name, 'firstAndThirdPartyAudienceType': 'FIRST_AND_THIRD_PARTY_AUDIENCE_TYPE_FIRST_PARTY', 'audienceType': 'CUSTOMER_MATCH_CONTACT_INFO', 'membershipDurationDays': 10000, 'contactInfoList': { 'contactInfos': [ contact_infos ], 'consent': { 'adUserData': ad-user-data-consent, 'adPersonalization': ad-personalization-consent } } } # Build and execute request. audience = service.firstAndThirdPartyAudiences().create( advertiserId=advertiser-id, body=audience_obj ).execute() # Display name of new audience. print('Customer Match audience %s was created.' % audience["name"])
PHP
// Create a Customer Match first- and third-party audience object. $audience = new Google_Service_DisplayVideo_FirstAndThirdPartyAudience(); $audience->setDisplayName(display-name); $audience->setFirstAndThirdPartyAudienceType( 'FIRST_AND_THIRD_PARTY_AUDIENCE_TYPE_FIRST_PARTY' ); $audience->setAudienceType('CUSTOMER_MATCH_CONTACT_INFO'); $audience->setMembershipDurationDays(10000); // Build list of contact information objects. $contactInfoList = new Google_Service_DisplayVideo_ContactInfoList(); $contactInfos = array(); foreach (list-of-hashed-phone-numbers as $hashedPhoneNumber) { $contactInfo = new Google_Service_DisplayVideo_ContactInfo(); $contactInfo->setHashedPhoneNumbers(array($hashedPhoneNumber)); $contactInfos[] = $contactInfo; } $contactInfoList->setContactInfos($contactInfos); // Build consent object for passing consent if granted by the end user. $consent = new Google_Service_DisplayVideo_Consent(); $consent->setAdUserData(ad-user-data-consent); $consent->setAdPersonalization(ad-personalization-consent); $contactInfoList->setConsent($consent); // Assign contactInfoList to audience object. $audience->setContactInfoList($contactInfoList); // Call the API, creating the audience. $result = $this->service->firstAndThirdPartyAudiences->create( $audience, array('advertiserId' => advertiser-id) ); // Display name of new audience. printf('Customer Match audience %s was created.', $result['name']);
更新目标客户匹配受众群体的成员资格
如果您确定了想要定位的其他客户,则需要
续订客户的或者想要移除客户
您可以更新某个现有客户的客户数据
将受众群体与
firstAndThirdPartyAudiences.editCustomerMatchMembers
方法。您可以使用
added_members
联合字段,并从
包含 removed_members
并集字段的列表。
单个
firstAndThirdPartyAudiences.editCustomerMatchMembers
请求只能向列表中添加成员或从中移除成员。单个请求尝试
都会导致 INVALID_ARGUMENT
错误。
以下示例说明了如何将单个客户添加为 联系信息 使用所提供的邮寄地址数据的目标客户匹配受众群体:
Java
// Create an edit members request object. EditCustomerMatchMembersRequest editCustomerMatchMembersRequest = new EditCustomerMatchMembersRequest() .setAdvertiserId(advertiser-id); // Build contact information object to add to audience. ContactInfoList contactInfoList = new ContactInfoList(); ArrayList<ContactInfo> contactInfos = new ArrayList<ContactInfo>(); ContactInfo contactInfo = new ContactInfo() .setHashedFirstName(hashed-customer-first-name) .setHashedLastName(hashed-customer-last-name) .setZipCodes(customer-zip-codes-list) .setCountryCode(customer-country-code); contactInfos.add(contactInfo); contactInfoList.setContactInfos(contactInfos); // Build consent object for passing consent if granted by the end user. Consent consent = new Consent() .setAdUserData(ad-user-data-consent) .setAdPersonalization(ad-personalization-consent); ContactInfoList.setConsent(consent); // Assign contact info list to request body. editCustomerMatchMembersRequest.setAddedContactInfoList(contactInfoList); // Edit Customer Match audience membership. EditCustomerMatchMembersResponse response = service .firstAndThirdPartyAudiences() .editCustomerMatchMembers( audience-id, editCustomerMatchMembersRequest ) .execute(); // Display ID of updated audience. System.out.printf( "The membership of Customer Match audience ID %s was edited.", response.getFirstAndThirdPartyAudienceId() );
Python
# Create an edit members request object. edit_member_request_obj = { 'advertiserId': advertiser-id, 'addedContactInfoList': { 'contactInfos': [ { 'hashedFirstName': hashed-customer-first-name, 'hashedLastName': hashed-customer-last-name, 'countryCode': customer-country-code, 'zipCodes': customer-zip-codes-list } ], 'consent': { 'adUserData': ad-user-data-consent, 'adPersonalization': ad-personalization-consent } } } # Build and execute request. response = service.firstAndThirdPartyAudiences().editCustomerMatchMembers( firstAndThirdPartyAudienceId=audience-id, body=edit_member_request_obj ).execute() # Display ID of updated audience. print('The membership of the Customer Match audience ID %s was updated.' % response["firstAndThirdPartyAudienceId"])
PHP
// Create an edit members request object. $editMemberRequest = new Google_Service_DisplayVideo_EditCustomerMatchMembersRequest(); $editMemberRequest->setAdvertiserId(advertiser-id); // Build contact information object to add to audience. $contactInfoList = new Google_Service_DisplayVideo_ContactInfoList(); $contactInfos = array(); $contactInfo = new Google_Service_DisplayVideo_ContactInfo(); $contactInfo->setHashedFirstName(hashed-customer-first-name); $contactInfo->setHashedLastName(hashed-customer-last-name); $contactInfo->setCountryCode(customer-country-code); $contactInfo->setZipCodes(array(customer-zip-codes-list)); $contactInfos[] = $contactInfo; $contactInfoList->setContactInfos($contactInfos); // Build consent object for passing consent if granted by the end user. $consent = new Google_Service_DisplayVideo_Consent(); $consent->setAdUserData(ad-user-data-consent); $consent->setAdPersonalization(ad-personalization-consent); $contactInfoList->setConsent($consent); // Assign contactInfoList to edit members request body. $editMemberRequest->setAddedContactInfoList($contactInfoList); // Call the API, editing the audience membership. $response = $this ->service ->firstAndThirdPartyAudiences ->editCustomerMatchMembers( audience-id, $editMemberRequest ); // Display ID of updated audience. printf( 'The membership of Customer Match audience ID %s was edited', $result['firstAndThirdPartyAudienceId'] );