La diffusion des annonces de génération de la demande est contrôlée à l'aide du ciblage attribué au partenaire parent, à l'annonceur, à l'élément de campagne et aux groupes d'annonces.
Utilisez le ciblage attribué à un groupe d'annonces et à un élément de campagne de génération de la demande pour toucher vos clients idéaux et améliorer les performances de vos campagnes.
Choisir où attribuer votre ciblage
Le ciblage peut être attribué aux éléments de campagne et aux groupes d'annonces de génération de la demande.
Attribuez un ciblage à un élément de campagne de génération de la demande si vous souhaitez qu'il s'applique à toutes les annonces diffusées dans cet élément de campagne. Sinon, attribuez le ciblage à des groupes d'annonces individuels.
Compatibilité du ciblage par type de ressource de génération de la demande
Chaque type de ressource est compatible avec certains types de ciblage.
Voici la liste des types de ciblage acceptés par les éléments de campagne de génération de la demande :
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
Voici la liste des types de ciblage acceptés par les groupes d'annonces de génération de la demande :
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
La compatibilité avec TARGETING_TYPE_GEO_REGION, TARGETING_TYPE_POI et TARGETING_TYPE_LANGUAGE dépend du paramètre du champ demandGenSettings.geoLanguageTargetingEnabled dans la ressource LineItem parente. Si la valeur du champ est "true", le ciblage géographique et linguistique ne peut être attribué qu'à l'élément de campagne parent. Si la valeur du champ est "false", ce ciblage ne peut être attribué qu'à des groupes d'annonces individuels.
Trouver les options de ciblage disponibles
Le ciblage est identifié en fonction de son type. Identifiez les options de ciblage de l'une des manières suivantes :
- Utilisez une valeur d'énumération pertinente, comme avec les types d'énumération
AgeRangeouExchange. - Récupérez les entités ciblables, telles que les chaînes ou les listes de zones géographiques, à l'aide du service associé.
- Récupérez les ID d'options de ciblage pour un type de ciblage à l'aide des méthodes
listetsearch.
Récupérer le ciblage existant
Le ciblage existant limite le ciblage qui peut être ajouté à un élément de campagne ou à un groupe d'annonces.
Les éléments de campagne et les groupes d'annonces de génération de la demande n'affichent que le ciblage TARGETING_TYPE_KEYWORD hérité. Cela signifie que vous devez récupérer le ciblage pour l'annonceur, l'élément de campagne et le groupe d'annonces afin de disposer d'un compte rendu complet de tous les ciblages ayant un impact sur la diffusion des annonces.
Récupérez le ciblage existant pour les différents types de ciblage à l'aide des requêtes bulk list.
Récupérer le ciblage existant des partenaires et des annonceurs
Voici comment obtenir le ciblage existant pour un annonceur, y compris le ciblage partenaire hérité :
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
Récupérer le ciblage d'un élément de campagne existant
Voici comment attribuer le ciblage existant directement à un élément de campagne :
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
Récupérer le ciblage d'un groupe d'annonces existant
Pour attribuer le ciblage existant directement à un groupe d'annonces :
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
Attribuer un ciblage aux ressources
Vous devez envoyer des requêtes distinctes pour mettre à jour le ciblage des éléments de campagne et des groupes d'annonces.
Attribuer le ciblage d'un élément de campagne
Voici comment ajouter la logique de ciblage suivante à un élément de campagne :
- Annonces diffusées uniquement sur les ordinateurs.
Ne pas enchérir sur l'inventaire diffusé à côté de contenu correspondant au mot clé "crème glacée".
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.")
Attribuer un ciblage de groupe d'annonces
Voici comment ajouter la logique de ciblage suivante à un groupe d'annonces :
- Ne diffuser qu'aux parents.
Ne pas diffuser d'annonces sur la chaîne YouTube indiquée.
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.")