您可以使用上传的客户联系信息或移动设备 ID 通过 Display & Video 360 API 创建目标客户匹配受众群体。本页介绍了如何使用 Display & Video 360 API 创建初始目标客户匹配受众群体,以及如何将新客户数据附加到现有受众群体。
准备用户数据
用于填充目标客户匹配受众群体的用户数据属于敏感数据,需要在上传之前进行适当准备。
对敏感数据进行哈希处理
有些目标客户匹配受众群体是使用敏感的客户联系信息创建的。Display & Video 360 要求在敏感数据上传之前,先使用 SHA256 算法对其进行哈希处理。以下数据字段必须先经过哈希处理,然后才能上传:
- 名字
- 姓氏
- 电子邮件地址
- 电话号码
邮政编码和国家/地区代码在上传之前不应进行哈希处理。尝试上传未经过哈希处理的客户数据会导致错误。
在对数据进行哈希处理之前,请确保满足以下条件:
- 必须从名字、姓氏和电子邮件地址值中移除所有空格。
- 所有值都必须采用小写形式。
- 所有电话号码都必须采用 E.164 格式,并包含国家/地区拨号代码。
设置用户意见征求
上传用户数据时,请使用所提供的 ContactInfoList
或 MobileDeviceIdList
对象中的 consent
字段,传递所包含用户授予的意见征求信号。
将 Consent
对象中的任一字段设置为 CONSENT_STATUS_DENIED
都会导致错误。
系统会为单个 firstAndThirdPartyAudiences.create
或 firstAndThirdPartyAudiences.editCustomerMatchMembers
请求中添加的所有用户设置意见征求信号。具有不同意见征求信号的用户必须在单独的请求中上传。
创建目标客户匹配受众群体
您可以使用 firstAndThirdPartyAudiences.create
方法创建目标客户匹配受众群体。该受众群体必须声明为第一方受众群体,并且 audienceType
必须为 CUSTOMER_MATCH_CONTACT_INFO
或 CUSTOMER_MATCH_DEVICE_ID
。必须使用联合字段 members
中的相应字段提供目标客户匹配数据。
以下示例展示了如何使用提供的经过哈希处理的电话号码列表,创建一个成员资格时长为 540 天的全新联系信息客户匹配信众群体:
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(540L); // 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': 540, '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(540); // 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'] );