デマンド ジェネレーション広告の配信は、親パートナー、広告主、広告申込情報、広告グループに割り当てられたターゲティングを使用して制御されます。
デマンド ジェネレーションの広告申込情報と広告グループに割り当てられたターゲティングを使用して、理想的なユーザーにリーチし、キャンペーンのパフォーマンスを向上させます。
ターゲティングの割り当て先を決める
ターゲティングは、デマンド ジェネレーション広告申込情報と広告グループの両方に割り当てることができます。
ターゲティングをデマンド ジェネレーション広告申込情報に割り当てると、その広告申込情報で配信されるすべての広告にターゲティングが適用されます。それ以外の場合は、個々の広告グループにターゲティングを割り当てます。
デマンド ジェネレーションのリソースタイプ別のターゲティングのサポート
リソースタイプごとに、特定のタイプのターゲティングがサポートされています。
デマンド ジェネレーション広告申込情報でサポートされているターゲティング タイプは次のとおりです。
TARGETING_TYPE_CARRIER_AND_ISPTARGETING_TYPE_DAY_AND_TIMETARGETING_TYPE_DEVICE_MAKE_MODELTARGETING_TYPE_DEVICE_TYPETARGETING_TYPE_GEO_REGIONTARGETING_TYPE_KEYWORDTARGETING_TYPE_LANGUAGETARGETING_TYPE_NEGATIVE_KEYWORD_LISTTARGETING_TYPE_OPERATING_SYSTEMTARGETING_TYPE_POI
デマンド ジェネレーション広告グループでサポートされているターゲティング タイプは次のとおりです。
TARGETING_TYPE_AGE_RANGETARGETING_TYPE_APPTARGETING_TYPE_APP_CATEGORYTARGETING_TYPE_AUDIENCE_GROUPTARGETING_TYPE_CATEGORYTARGETING_TYPE_GENDERTARGETING_TYPE_GEO_REGIONTARGETING_TYPE_HOUSEHOLD_INCOMETARGETING_TYPE_KEYWORDTARGETING_TYPE_LANGUAGETARGETING_TYPE_PARENTAL_STATUSTARGETING_TYPE_URLTARGETING_TYPE_YOUTUBE_CHANNELTARGETING_TYPE_YOUTUBE_VIDEO
TARGETING_TYPE_GEO_REGION、TARGETING_TYPE_POI、TARGETING_TYPE_LANGUAGE のサポートは、親 LineItem リソースの demandGenSettings.geoLanguageTargetingEnabled フィールドの設定によって異なります。フィールドが true の場合、地域と言語のターゲティングは親広告申込情報にのみ割り当てることができます。フィールドが false の場合、このターゲティングは個々の広告グループにのみ割り当てることができます。
利用可能なターゲティング オプションを確認する
ターゲティングはタイプに基づいて識別されます。次のいずれかの方法でターゲティング オプションを特定します。
AgeRangeやExchangeなどの列挙型を使用して、関連する列挙値を使用します。- 関連するサービスを使用して、チャンネルや地域リストなどのターゲット設定可能なエンティティを取得します。
listメソッドとsearchメソッドを使用して、ターゲティング タイプのターゲティング オプション ID を取得します。
既存のターゲティングを取得する
既存のターゲティングにより、広告申込情報または広告グループに追加できるターゲティングが制限されます。
デマンド ジェネレーション広告申込情報と広告グループには、継承された TARGETING_TYPE_KEYWORD ターゲティングのみが表示されます。つまり、広告配信に影響するすべてのターゲティングを完全に把握するには、広告主、広告申込情報、広告グループのターゲティングを取得する必要があります。
一括リスト リクエストを使用して、ターゲティング タイプ全体で既存のターゲティングを取得します。
既存のパートナーと広告主のターゲティングを取得する
継承されたパートナー ターゲティングを含む、広告主の既存のターゲティングを取得する方法は次のとおりです。
Python
# Provide the ID of the advertiser. advertiser_id = advertiser-id # Create the page token variable. next_page_token = "" while True: # Execute the list request. response = ( service.advertisers() .listAssignedTargetingOptions( advertiserId=advertiser_id, pageToken=next_page_token, ) .execute() ) # If response is not empty, display the retrieved assigned targeting # options. if response: for assigned_targeting_option in response.get( "assignedTargetingOptions", [] ): ato_name = assigned_targeting_option.get( "name", None ) if ato_name: print(f"Assigned Targeting Option {ato_name}.") else: print(f"No targeting is currently assigned to {advertiser_id}.") sys.exit(1) # Update the next page token. # Break out of loop if there is no next page. if "nextPageToken" in response: next_page_token = response["nextPageToken"] else: break
既存の広告申込情報のターゲティングを取得する
既存のターゲティングを広告申込情報に直接割り当てる手順は次のとおりです。
Python
# Provide the ID of the parent advertiser. advertiser_id = advertiser-id # Provide the ID of the Demand Gen line item. line_item_id = line-item-id # Create the page token variable. next_page_token = "" while True: # Execute the list request. response = ( service.advertisers() .lineItems() .bulkListAssignedTargetingOptions( advertiserId=advertiser_id, lineItemIds=[line_item_id], pageToken=next_page_token, ) .execute() ) # If response is not empty, display the retrieved assigned targeting # options line items. if response: for assigned_option in response.get( "lineItemAssignedTargetingOptions", [] ): ato_name = assigned_option.get("assignedTargetingOption", {}).get( "name", None ) if ato_name: print(f"Assigned Targeting Option {ato_name} found.") else: print(f"No targeting is currently assigned to {line_item_id}.") sys.exit(1) # Update the next page token. # Break out of loop if there is no next page. if "nextPageToken" in response: next_page_token = response["nextPageToken"] else: break
既存の広告グループのターゲット設定を取得する
既存のターゲティングを広告グループに直接割り当てる方法は次のとおりです。
Python
# Provide the ID of the parent advertiser. advertiser_id = advertiser-id # Provide the ID of the ad group. ad_group_id = ad-group-id # Create the page token variable. next_page_token = "" while True: # Execute the list request. response = ( service.advertisers() .adGroups() .bulkListAssignedTargetingOptions( advertiserId=advertiser_id, adGroupIds=[ad_group_id], pageToken=next_page_token, ) .execute() ) # If response is not empty, display the retrieved assigned targeting # options line items. if response: for assigned_option in response.get( "adGroupAssignedTargetingOptions", [] ): ato_name = assigned_option.get("assignedTargetingOption", {}).get( "name", None ) if ato_name: print(f"Assigned Targeting Option {ato_name} found.") else: print(f"No targeting is currently assigned to {ad_group_id}.") sys.exit(1) # Update the next page token. # Break out of loop if there is no next page. if "nextPageToken" in response: next_page_token = response["nextPageToken"] else: break
リソースにターゲティングを割り当てる
広告申込情報と広告グループのターゲティングを更新するには、個別のリクエストを行う必要があります。
広告申込情報のターゲティングを割り当てる
広告申込情報に次のターゲティング ロジックを追加する方法は次のとおりです。
- パソコンでのみ広告が配信されました。
キーワード「アイスクリーム」に一致するコンテンツとともに配信される広告枠に入札しない。
Python
# Provide the ID of the parent advertiser. advertiser_id = advertiser-id # Provide the ID of the line item. line_item_id = line-item-id # Build the "ice cream" negative keyword assigned targeting option. keyword_assigned_targeting_option = { "keywordDetails": {"keyword": "ice cream", "negative": True} } # Build the delete request for device type targeting to remove all device # types to only target computers. device_type_delete_request = { "targetingType": "TARGETING_TYPE_DEVICE_TYPE", "assignedTargetingOptionIds": [ "DEVICE_TYPE_SMART_PHONE", "DEVICE_TYPE_CONNECTED_TV", "DEVICE_TYPE_TABLET" ], } # Create a bulk edit request. bulk_edit_targeting_request = { "lineItemIds": [line_item_id], "createRequests": [ { "targetingType": "TARGETING_TYPE_KEYWORD", "assignedTargetingOptions": [ keyword_assigned_targeting_option ], } ], "deleteRequests": [ device_type_delete_request ] } # Build and execute request. response = ( service.advertisers() .lineItems() .bulkEditAssignedTargetingOptions( advertiserId=advertiser_id, body=bulk_edit_targeting_request ) .execute() ) # Print the request results. if ( "updatedLineItemIds" in response and len(response["updatedLineItemIds"]) != 0 ): print( f'Targeting configurations for {response["updatedLineItemIds"][0]} ' "were successfully updated." ) elif ( "failedLineItemIds" in response and len(response["failedLineItemIds"]) != 0 ): print( f'Targeting configurations for {response["failedLineItemIds"][0]} ' "failed to update." ) if "errors" in response and len(response["errors"]) != 0: print("The failed updates were caused by the following errors:") for error in response["errors"]: print(f'Code {error["code"]}: {error["message"]}') else: print("No successful or failed updates were reported.")
広告グループのターゲティングを割り当てる
広告グループに次のターゲティング ロジックを追加する方法は次のとおりです。
- 保護者のみに配信します。
指定された YouTube チャンネルに対して広告を配信しない。
Python
# Provide the ID of the parent advertiser. advertiser_id = advertiser-id # Provide the ID of the ad group. ad_group_id = ad-group-id # Provide the YouTube channel ID to negatively target. yt_channel_id = youtube-channel-id # Build the assigned targeting option to negatively target the given YouTube # channel. youtube_channel_assigned_targeting_options = [ { "youtubeChannelDetails": { "channelId": yt_channel_id, "negative": True } }, ] # Build the assigned targeting options to target only parents. parental_status_assigned_targeting_options = [ { "parentalStatusDetails": { "parentalStatus": "PARENTAL_STATUS_PARENT" } }, ] # Create a bulk edit request. bulk_edit_targeting_request = { "adGroupIds": [ad_group_id], "createRequests": [ { "targetingType": "TARGETING_TYPE_YOUTUBE_CHANNEL", "assignedTargetingOptions": ( youtube_channel_assigned_targeting_options ) }, { "targetingType": "TARGETING_TYPE_PARENTAL_STATUS", "assignedTargetingOptions": ( parental_status_assigned_targeting_options ), } ] } # Build and execute request. response = ( service.advertisers() .adGroups() .bulkEditAssignedTargetingOptions( advertiserId=advertiser_id, body=bulk_edit_targeting_request ) .execute() ) # Print the request results. if ( "updatedAdGroupIds" in response and len(response["updatedAdGroupIds"]) != 0 ): print( f'Targeting configurations for {response["updatedAdGroupIds"][0]} ' "were successfully updated." ) elif ( "failedAdGroupIds" in response and len(response["failedAdGroupIds"]) != 0 ): print( f'Targeting configurations for {response["failedAdGroupIds"][0]} ' "failed to update." ) if "errors" in response and len(response["errors"]) != 0: print("The failed updates were caused by the following errors:") for error in response["errors"]: print(f'Code {error["code"]}: {error["message"]}') else: print("No successful or failed updates were reported.")