对资源定位的管理是展示广告系列和Video 360 API。 定位可以分配给多种资源类型,并利用多种 其他资源和 ID 空间。本页详细介绍了需要注意的限制和最佳实践 实施展示广告系列和Video 360 API 指定的定位 选项服务。
利用定位继承功能
分配给某些资源的定位可以由其子级继承 资源。子资源继承的定位选项可以检索,但 无法在子资源级别修改。此设置会启用品牌保障设置 在整个合作伙伴或广告客户范围内强制执行其他定位条件。
继承路径如下图所示:
如图所示,某些定位级别仅支持 定位类型。也就是说,有些定位选项不能以更高的价格 但需要在较低级别进行设置。
YouTube 中的继承和合作伙伴资源
定位沿用设置不会反映在 YouTube 和合作伙伴资源
展示广告与Video 360 API。广告组沿用的定位条件将不会
可在 AdGroup
级别和 YouTube 定位上检索
子资源无法继承父资源的继承。
要获取广告组的所有功能定位设置,您需要 应检索为广告组分配的定位选项, 父级订单项和父级广告客户。
请注意在创建订单项时分配的定位条件
除了继承的定位选项外,大多数定位都只能指定给 创建订单项后不过,也有一些定位类型 在创建订单项时分配给订单项的默认子集。这些 定位类型包括:
尝试创建现有的或删除不存在的已分配定位选项
会返回错误,因此我们建议您了解完整的定位套件,
创建的新订单项如果您需要检索
向某个订单项分配多个定位条件时,请使用
advertisers.lineItems.bulkListAssignedTargetingOptions
。
另外,如果没有定位选项,系统会默认指定某些设置
分配给资源的类型。例如,如果某个资源没有
TARGETING_TYPE_AUTHORIZED_SELLER_STATUS
定位选项,这意味着它使用的是“已获授权的直接”
销售商和转销商”状态。
不会期望系统自动采用“默认定位”
展示广告和对于 Video 360,在广告系列或广告订单级别设置的定位条件现为 不会立即传递给其子订单项。这种定位条件称为 “默认定位”用作定位模板 应用于随后在界面中创建的订单项
在展示广告和Video 360 API,默认定位条件不会自动应用于新 创建订单项。基本的订单项创建操作不会复制到任何广告系列 或广告订单级定位条件在这种情况下,所需的定位条件必须是 通过已分配的定位选项单独应用于订单项 create 或批量修改方法。
特殊方法可以是例外情况。例如,通过
advertisers.lineItems.generateDefault
副本
设置,包括已分配的定位条件。
同样,通过复制创建的订单项也会被分配
与原始订单项的定位条件相同
YouTube 和无法修改合作伙伴定位条件
专门针对 YouTube 和无法使用以下应用更新合作伙伴广告系列: 展示广告和Video 360 API。
YouTube 和合作伙伴定位包括所有直接分配给 YouTube 和合作伙伴订单项和广告组,以及 以下任一定位类型:
TARGETING_TYPE_SESSION_POSITION
TARGETING_TYPE_YOUTUBE_CHANNEL
TARGETING_TYPE_YOUTUBE_VIDEO
您可以使用“展示广告和直接或通过 上传结构化数据文件的步骤如下:
使用单个选项指定受众群体定位
大多数定位类型的定位选项都是单独指定的。观众
组定位不遵循此模块化惯例,而是被分配
配置一个
受众群体定位详情对象,其中会列出
投放广告时要包含和排除的受众群体的 ID。通过
assignedTargetingOptionId
(对于此目标对象群组选项),
分配后,始终为“audienceGroup”。
这种设计意味着,对受众群体定位条件做出的任何更改都必须
首先删除已分配的现有目标对象群组
定位选项,然后创建新的受众群体组
具有所需更改的定位选项。只需一个请求即可完成此操作
使用
advertisers.lineItems.bulkEditAssignedTargetingOptions
。
下例说明了如何更新受众群体定位 定位其他 Google 受众群体:
Java
long advertiserId = advertiser-id; long lineItemId = line-item-id List<Long> addedGoogleAudienceIds = Arrays.asList(google-audience-id-to-add,...); // Build Google audience targeting settings objects to add to audience // targeting. ArrayList<GoogleAudienceTargetingSetting> newGoogleAudienceSettings = new ArrayList<GoogleAudienceTargetingSetting>(); // Convert list of Google Audience IDs into list of settings. for (Long googleAudienceId : addedGoogleAudienceIds) { newGoogleAudienceSettings.add(new GoogleAudienceTargetingSetting() .setGoogleAudienceId(googleAudienceId)); } // Create relevant bulk edit request objects. BulkEditLineItemAssignedTargetingOptionsRequest requestContent = new BulkEditLineItemAssignedTargetingOptionsRequest(); AudienceGroupAssignedTargetingOptionDetails updatedAudienceGroupDetails; ArrayList<DeleteAssignedTargetingOptionsRequest> audienceGroupDeleteRequests = new ArrayList<DeleteAssignedTargetingOptionsRequest>(); try { // Retrieve existing audience group targeting. AssignedTargetingOption existingAudienceGroupTargetingOption = service .advertisers() .lineItems() .targetingTypes() .assignedTargetingOptions() .get( advertiserId, lineItemId, "TARGETING_TYPE_AUDIENCE_GROUP", "audienceGroup" ).execute(); // Extract existing audience group targeting details. updatedAudienceGroupDetails = existingAudienceGroupTargetingOption.getAudienceGroupDetails(); // Build and add delete request for existing audience group targeting. ArrayList<String> deleteAudienceGroupAssignedTargetingIds = new ArrayList<String>(); deleteAudienceGroupAssignedTargetingIds.add("audienceGroup"); audienceGroupDeleteRequests .add(new DeleteAssignedTargetingOptionsRequest() .setTargetingType("TARGETING_TYPE_AUDIENCE_GROUP") .setAssignedTargetingOptionIds( deleteAudienceGroupAssignedTargetingIds ) ); } catch (GoogleJsonResponseException e) { updatedAudienceGroupDetails = new AudienceGroupAssignedTargetingOptionDetails(); } // Set delete requests in edit request. requestContent.setDeleteRequests(audienceGroupDeleteRequests); // Construct new group of Google Audiences to include in targeting. GoogleAudienceGroup updatedIncludedGoogleAudienceGroup = updatedAudienceGroupDetails.getIncludedGoogleAudienceGroup(); if (updatedIncludedGoogleAudienceGroup != null) { List<GoogleAudienceTargetingSetting> updatedGoogleAudienceSettings = updatedIncludedGoogleAudienceGroup.getSettings(); updatedGoogleAudienceSettings.addAll(newGoogleAudienceSettings); updatedIncludedGoogleAudienceGroup .setSettings(updatedGoogleAudienceSettings); } else { updatedIncludedGoogleAudienceGroup = new GoogleAudienceGroup(); updatedIncludedGoogleAudienceGroup.setSettings(newGoogleAudienceSettings); } // Add new Google Audience group to audience group targeting details. updatedAudienceGroupDetails .setIncludedGoogleAudienceGroup(updatedIncludedGoogleAudienceGroup); // Create new targeting option to assign. AssignedTargetingOption newAudienceGroupTargeting = new AssignedTargetingOption(); newAudienceGroupTargeting .setAudienceGroupDetails(updatedAudienceGroupDetails); // Build audience group targeting create request and add to list of create // requests. ArrayList<AssignedTargetingOption> createAudienceGroupAssignedTargetingOptions = new ArrayList<AssignedTargetingOption>(); createAudienceGroupAssignedTargetingOptions.add(newAudienceGroupTargeting); ArrayList<CreateAssignedTargetingOptionsRequest> targetingCreateRequests = new ArrayList<CreateAssignedTargetingOptionsRequest>(); targetingCreateRequests.add(new CreateAssignedTargetingOptionsRequest() .setTargetingType("TARGETING_TYPE_AUDIENCE_GROUP") .setAssignedTargetingOptions( createAudienceGroupAssignedTargetingOptions ) ); // Set create requests in edit request. requestContent.setCreateRequests(targetingCreateRequests); // Configure and execute the bulk list request. BulkEditLineItemAssignedTargetingOptionsResponse response = service.advertisers().lineItems() .bulkEditLineItemAssignedTargetingOptions( advertiserId, lineItemId, requestContent).execute();
Python
advertiser_id = advertiser-id line_item_id = line-item-id added_google_audiences = [google-audience-id-to-add,...] # Build Google audience targeting settings objects to create. new_google_audience_targeting_settings = [] for google_audience_id in added_google_audiences: new_google_audience_targeting_settings.append( {'googleAudienceId': google_audience_id} ) # Retrieve any existing line item audience targeting. retrieved_audience_targeting = service.advertisers().lineItems( ).targetingTypes().assignedTargetingOptions().get( advertiserId=advertiser_id, lineItemId=line_item_id, targetingType="TARGETING_TYPE_AUDIENCE_GROUP", assignedTargetingOptionId="audienceGroup" ).execute() updated_audience_group_details = {} # Copy over any existing audience targeting. if 'audienceGroupDetails' in retrieved_audience_targeting: updated_audience_group_details = retrieved_audience_targeting[ 'audienceGroupDetails'] # Append the new Google audience IDs to any existing positive Google # audience targeting. if 'includedGoogleAudienceGroup' in updated_audience_group_details: updated_audience_group_details[ 'includedGoogleAudienceGroup']['settings'].extend( new_google_audience_targeting_settings) else: updated_audience_group_details['includedGoogleAudienceGroup'] = { 'settings': new_google_audience_targeting_settings } # Build bulk edit request. bulk_edit_request = { 'deleteRequests': [ { 'targetingType': "TARGETING_TYPE_AUDIENCE_GROUP", 'assignedTargetingOptionIds': [ "audienceGroup" ] } ], 'createRequests': [ { 'targetingType': "TARGETING_TYPE_AUDIENCE_GROUP", 'assignedTargetingOptions': [ {'audienceGroupDetails': updated_audience_group_details} ] } ] } # Update the audience targeting updated_audience_targeting = service.advertisers().lineItems( ).bulkEditLineItemAssignedTargetingOptions( advertiserId=advertiser_id, lineItemId=line_item_id, body=bulk_edit_request ).execute()
PHP
$advertiserId = advertiser-id; $lineItemId = line-item-id; $addedGoogleAudienceIds = array(google-audience-id-to-add,...); // Convert list of Google Audience IDs into list of Google audience // settings. $newGoogleAudienceSettings = array(); foreach ($addedGoogleAudienceIds as $googleAudienceId) { $newSetting = new Google_Service_DisplayVideo_GoogleAudienceTargetingSetting(); $newSetting->setGoogleAudienceId($googleAudienceId); $newGoogleAudienceSettings[] = $newSetting; } // Create a bulk edit request. $requestBody = new Google_Service_DisplayVideo_BulkEditLineItemAssignedTargetingOptionsRequest(); $audienceGroupDeleteRequests = array(); try { // Retrieve existing audience group targeting. $existingAudienceGroupTargetingOption = $this ->service ->advertisers_lineItems_targetingTypes_assignedTargetingOptions ->get( $advertiserId, $lineItemId, 'TARGETING_TYPE_AUDIENCE_GROUP', 'audienceGroup' ); // Extract existing audience group targeting details. $updatedAudienceGroupDetails = $existingAudienceGroupTargetingOption ->getAudienceGroupDetails(); // Build and add delete request for existing audience group // targeting. $deleteAudienceGroupAssignedTargetingIds = array(); $deleteAudienceGroupAssignedTargetingIds[] = "audienceGroup"; $audienceGroupDeleteRequest = new Google_Service_DisplayVideo_DeleteAssignedTargetingOptionsRequest(); $audienceGroupDeleteRequest ->setTargetingType('TARGETING_TYPE_AUDIENCE_GROUP'); $audienceGroupDeleteRequest ->setAssignedTargetingOptionIds( $deleteAudienceGroupAssignedTargetingIds ); $audienceGroupDeleteRequests[] = $audienceGroupDeleteRequest; } catch (\Exception $e) { $updatedAudienceGroupDetails = new Google_Service_DisplayVideo_AudienceGroupAssignedTargetingOptionDetails(); } // Set delete requests in edit request. $requestBody->setDeleteRequests($audienceGroupDeleteRequests); // Construct new group of Google audiences to include in targeting. $updatedIncludedGoogleAudienceGroup = $updatedAudienceGroupDetails ->getIncludedGoogleAudienceGroup(); if (!empty($updatedIncludedGoogleAudienceGroup)) { // Get existing settings. $updatedGoogleAudienceSettings = $updatedIncludedGoogleAudienceGroup->getSettings(); // Add new Google audiences to existing list. $updatedGoogleAudienceSettings = array_merge( $updatedGoogleAudienceSettings, $newGoogleAudienceSettings ); // Set updated Google audience list. $updatedIncludedGoogleAudienceGroup ->setSettings($updatedGoogleAudienceSettings); } else { // Create new Google audience group. $updatedIncludedGoogleAudienceGroup = new Google_Service_DisplayVideo_GoogleAudienceGroup(); // Set list of new Google audiences for targeting. $updatedIncludedGoogleAudienceGroup ->setSettings($newGoogleAudienceSettings); } // Add new Google Audience group to audience group targeting details. $updatedAudienceGroupDetails ->setIncludedGoogleAudienceGroup( $updatedIncludedGoogleAudienceGroup ); // Create new targeting option to assign. $newAudienceGroupTargeting = new Google_Service_DisplayVideo_AssignedTargetingOption(); $newAudienceGroupTargeting ->setAudienceGroupDetails($updatedAudienceGroupDetails); // Build audience group targeting create request and add to list of // create requests. $createAudienceGroupAssignedTargetingOptions = array(); $createAudienceGroupAssignedTargetingOptions[] = $newAudienceGroupTargeting; $createAudienceGroupTargetingRequest = new Google_Service_DisplayVideo_CreateAssignedTargetingOptionsRequest(); $createAudienceGroupTargetingRequest->setTargetingType( "TARGETING_TYPE_AUDIENCE_GROUP" ); $createAudienceGroupTargetingRequest->setAssignedTargetingOptions( $createAudienceGroupAssignedTargetingOptions ); $createRequests[] = $createAudienceGroupTargetingRequest; // Set create requests in edit request. $requestBody->setCreateRequests($createRequests); // Call the API, editing the assigned targeting options for the // identified line item. $response = $this ->service ->advertisers_lineItems ->bulkEditLineItemAssignedTargetingOptions( $advertiserId, $lineItemId, $requestBody );
为定位选项被弃用做好准备
定位选项不是静态的,我们可能会逐步弃用少数定位选项 。定位选项被弃用后,不会影响订单项的广告 。弃用后,这些选项将从现有订单项中取消分配 尝试检索或分配这些选项的项和请求会导致 出错。
为了避免这些错误,我们建议您定期检查存储的
定位选项 ID。为了节省配额,我们建议您
常用的 ID。不过,存储 ID 意味着
某个定位选项已弃用。因此,您应该
经常使用 targetingOptions.targetingTypes.get
执行以下操作:
请检索存储的所有定位选项 ID,以确认它们仍
展示广告和Video 360。
如需详细了解重要的弃用功能,请参阅我们的已公布弃用页面。 以及即将进行的弃用
请勿同时发送更新同一订单项的请求
尝试更新单个订单项的设置或分配的定位条件 则系统将返回错误适用的请求 包括:
advertisers.lineItems.bulkEditAssignedTargetingOptions
advertisers.lineItems.bulkUpdate
advertisers.lineItems.patch
advertisers.lineItems.targetingTypes.assignedTargetingOptions.create
advertisers.lineItems.targetingTypes.assignedTargetingOptions.delete
如果您需要为某个
您应该使用一个
advertisers.lineItems.bulkEditAssignedTargetingOptions
请求。如果您想更新订单项的设置和定位,请加入队列
patch
或 bulkUpdate
请求,以及
定位请求,以确保在发出第一个请求后
返回响应。