リソース ターゲティングの管理は、Display & Video 360 API の中心的な機能です。 ターゲティングは複数のリソースタイプに割り当てることができ、他の多くのリソースや ID 空間を利用します。このページでは、Display & Video 360 API の割り当て済みターゲティング オプション サービスを導入する際に留意すべき制限事項と実装すべきベスト プラクティスについて詳しく説明します。
ターゲティングの継承を利用する
一部のリソースに割り当てられたターゲティングは、その子リソースに継承できます。子リソースによって継承されたターゲティング オプションは、取得は可能ですが、子リソースレベルでは編集できません。これにより、ブランド保護設定やその他のターゲティングをパートナーまたは広告主全体に適用できます。
次の図に、継承の過程を示します。
図に示されているように、一部のターゲティング レベルは一部のターゲティング タイプにのみ対応しています。つまり、一部のターゲティング オプションは上位レベルで設定して継承することはできませんが、下位レベルで設定する必要があります。
YouTube とパートナーのリソースにおける継承
ターゲティングの継承は、Display & Video 360 API の YouTube とパートナーのリソースには反映されません。広告グループによって継承されたターゲティングは、AdGroup
レベルでは取得されず、親リソースに割り当てられた YouTube ターゲティングは子リソースに継承されません。
広告グループの機能ターゲティング設定をすべて取得するには、広告グループ、親広告申込情報、親広告主に割り当てられているターゲティング オプションを取得する必要があります。
広告申込情報の作成時に割り当てられるターゲティングに注意する
継承されたターゲティング オプション以外では、ほとんどのターゲティングは広告申込情報の作成後にのみ割り当てることができます。ただし、ターゲティング タイプの中には、広告申込情報の作成時に広告申込情報にデフォルトで割り当てられる値のサブセットがあるものもあります。該当するターゲティング タイプは次のとおりです。
割り当て済みの既存のターゲティング オプションを作成したり、割り当てられていないターゲティング オプションを削除しようとすると、エラーが返されます。そのため、作成時に広告申込情報に割り当てられている完全なターゲティング スイートを確認することをおすすめします。広告申込情報に割り当てられたターゲティングを複数のターゲティング タイプにわたって取得する必要がある場合は、advertisers.lineItems.bulkListAssignedTargetingOptions
を使用します。
また、リソースにそのタイプのターゲティング オプションが割り当てられていない場合、デフォルトで設定される項目もあります。たとえば、リソースに TARGETING_TYPE_AUTHORIZED_SELLER_STATUS
ターゲティング オプションが定義されていない場合、「認定直接販売者と認定販売パートナー」ステータスが使用されています。
自動の「デフォルトのターゲティング」は設定されない
ディスプレイ &ビデオ 360 では、キャンペーン単位または広告掲載オーダー単位で設定されたターゲティングが、すぐに子広告申込情報に渡されることはありません。このターゲティングは「デフォルトのターゲティング」と呼ばれ、後から管理画面で作成される広告申込情報に適用されるターゲティング テンプレートとして使用されます。
Display & Video 360 API では、新しく作成した広告申込情報にデフォルトのターゲティングが自動的に適用されることはありません。基本的な広告申込情報を作成すると、キャンペーン単位や広告掲載オーダー レベルのターゲティングはコピーされません。この場合、割り当てられたターゲティング オプションの作成または一括編集の方法を使用して、必要なターゲティングを広告申込情報に個別に適用する必要があります。
特殊なメソッドは例外です。たとえば、advertisers.lineItems.generateDefault
で作成した広告申込情報では、親広告掲載オーダーの設定(割り当て済みのターゲティングを含む)がコピーされます。
同様に、複製によって作成された広告申込情報には、元の広告申込情報と同じターゲティングが割り当てられます。
YouTube とパートナーのターゲティングは変更できません
YouTube とパートナーのキャンペーン専用のターゲティングは、Display & Video 360 API を使用して更新することはできません。
YouTube とパートナーのターゲティングは、YouTube とパートナーの広告申込情報と広告グループに直接割り当てられたすべてのターゲティングと、以下のターゲティング タイプのターゲティングで構成されます。
TARGETING_TYPE_SESSION_POSITION
TARGETING_TYPE_YOUTUBE_CHANNEL
TARGETING_TYPE_YOUTUBE_VIDEO
このターゲティングは、ディスプレイ &ビデオ 360 の管理画面から直接更新するか、構造化データファイルをアップロードして更新できます。
オーディエンス ターゲティングを 1 つのオプションで割り当てる
ほとんどのターゲティング タイプでは、ターゲティング オプションは個別に割り当てられます。オーディエンス グループ ターゲティングは、モジュール方式ではなく、広告配信時に含めるオーディエンスの ID と除外するオーディエンスの ID をリストした、単一の設定可能なオーディエンス グループのターゲティングの詳細オブジェクトに割り当てられます。このオーディエンス グループ オプションの assignedTargetingOptionId
は、一度割り当てられると、常に「audienceGroup」になります。
つまり、オーディエンス グループのターゲティングを変更するには、まず既存のオーディエンス グループに割り当てられているターゲティング オプションを削除してから、必要な変更を加えた新しいオーディエンス グループ ターゲティング オプションを作成する必要があります。これは、advertisers.lineItems.bulkEditAssignedTargetingOptions
を使用して 1 回のリクエストで行うことができます。
以下は、オーディエンス ターゲティングを更新して、他の 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 を取得し、ディスプレイ &ビデオ 360 で引き続きサポートされていることを確認する必要があります。
以前および予定されている非推奨の詳細については、発表された非推奨のページをご覧ください。
同じ広告申込情報に対する同時リクエストを同時に実行しない
複数の同時リクエストを使用して 1 つの広告申込情報の設定や割り当てられているターゲティングを更新しようとすると、エラーが返されます。該当するリクエストは次のとおりです。
advertisers.lineItems.bulkEditAssignedTargetingOptions
advertisers.lineItems.bulkUpdate
advertisers.lineItems.patch
advertisers.lineItems.targetingTypes.assignedTargetingOptions.create
advertisers.lineItems.targetingTypes.assignedTargetingOptions.delete
1 つの広告申込情報で複数のターゲティング オプションの割り当てをまとめて追加または削除する必要がある場合は、1 つの advertisers.lineItems.bulkEditAssignedTargetingOptions
リクエストを使用してください。広告申込情報の設定とターゲティングを更新するには、patch
または bulkUpdate
リクエストおよび関連するターゲティング リクエストをキューに入れて、最初のリクエストからレスポンスが返されるまで 2 番目のリクエストが送信されないようにします。