Kierowanie na listy odbiorców umożliwia kierowanie reklam na różne grupy odbiorców. Wszystkie grupy odbiorców, na które kierujesz reklamy, mogą być różnych typów.
Kierowanie na wszystkie listy odbiorców odbywa się za pomocą jednej przypisanej opcji kierowania typu TARGETING_TYPE_AUDIENCE_GROUP.
Logika kierowania na odbiorców
Przypisana opcja kierowania na odbiorców zawiera obiekt szczegóły kierowania na odbiorców. Kierowanie na odbiorców to łączny wynik pól obiektu szczegółowego. Ten wynik jest oparty na tej logice:
- Każdy obiekt grupy odbiorców to lista odbiorców połączonych za pomocą operacji UNION.
- Pole
includedFirstPartyAndPartnerAudienceGroupszawiera listę grup odbiorców. Łączy grupy odbiorców za pomocą funkcji INTERSECTION. - Wszystkie pola z prefiksem „included” reprezentują listy użytkowników, na które można kierować reklamy. Są one łączone za pomocą operatora UNION. W wyniku tego otrzymasz listę użytkowników, których możesz uwzględnić w kierowaniu.
- Wszystkie pola z prefiksem „excluded” reprezentują listy użytkowników, które należy wykluczyć z kierowania. Są one łączone za pomocą operatora UNION. W wyniku tego otrzymasz listę użytkowników, których chcesz wykluczyć z kierowania.
- Kierowanie będzie obejmować wszystkich uwzględnionych użytkowników, którzy nie znajdują się na liście wykluczonych użytkowników. Jeśli wykluczone są tylko listy użytkowników, kierowanie będzie obejmować wszystkich użytkowników z wyjątkiem tych, którzy zostali wykluczeni.
W praktyce oznacza to 2 rzeczy. Po pierwsze, reklamy nie będą kierowane na użytkownika, jeśli znajduje się on na liście odbiorców w polu „Wykluczeni”. Po drugie, użytkownik będzie objęty kierowaniem, jeśli spełniony jest jeden z tych warunków:
- Występują w grupie odbiorców w każdej grupie odbiorców w
includedFirstPartyAndPartnerAudienceGroups. - występują w dowolnych odbiorcach w dowolnym innym polu „Uwzględnieni”.
- Nie ustawiono pola „included”.
Aktualizowanie kierowania na odbiorców
Kierowanie na listę odbiorców korzysta z przypisanej opcji kierowania z wartością ID „audienceGroup”. Aby skonfigurować kierowanie na odbiorców, musisz:
- Pobierz dowolną istniejącą listę odbiorców, do której przypisano opcję kierowania.
- Utwórz nowy obiekt przypisanej opcji kierowania. Jeśli istnieje już kierowanie, ten obiekt powinien być oparty na dotychczasowym kierowaniu z uwzględnieniem wprowadzonych zmian.
- W razie potrzeby usuń istniejącą przypisaną opcję kierowania.
- Utwórz nową przypisaną opcję kierowania.
Można to zrobić za pomocą metod list i bulkEditAssignedTargetingOptions.
Aby zaktualizować kierowanie na odbiorców w elemencie zamówienia:
Java
// Provide the ID of the parent advertiser. long advertiserId = advertiser-id; // Provide the ID of the line item whose targeting will be updated. long lineItemId = line-item-id; // Provide a list of Google Audience IDs to add to line item targeting. List<Long> addedGoogleAudienceIds = google-audience-ids-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. BulkEditAssignedTargetingOptionsRequest requestContent = new BulkEditAssignedTargetingOptionsRequest(); requestContent.setLineItemIds(Arrays.asList(lineItemId)); 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 (Exception 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 edit request. BulkEditAssignedTargetingOptionsResponse response = service .advertisers() .lineItems() .bulkEditAssignedTargetingOptions(advertiserId, requestContent) .execute(); // Display API response information. if (response.getUpdatedLineItemIds() != null && !response.getUpdatedLineItemIds().isEmpty()) { System.out.printf( "Targeting configurations for %s were successfully updated.%n", response.getUpdatedLineItemIds().get(0)); } if (response.getFailedLineItemIds() != null && !response.getFailedLineItemIds().isEmpty()) { System.out.printf( "Targeting configurations for %s failed to update.%n", response.getFailedLineItemIds().get(0)); } if (response.getErrors() != null && !response.getErrors().isEmpty()) { System.out.println("The failed updates were caused by the following errors:"); for (Status error : response.getErrors()) { System.out.printf("Code %s: %s%n", error.getCode(), error.getMessage()); } } else { System.out.println("No successful or failed updates were reported."); }
Python
# Provide the ID of the parent advertiser. advertiser_id = advertiser-id # Provide the ID of the line item whose targeting will be updated. line_item_id = line-item-id # Provide a list of Google Audience IDs to add to line item targeting. added_google_audiences = google-audience-ids-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} ) try: # 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() ) except Exception: print( 'Error retrieving existing audience targeting. Assuming no ' 'existing audience targeting.' ) retrieved_audience_targeting = {} 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 = { 'lineItemIds': [line_item_id], 'deleteRequests': [{ 'targetingType': 'TARGETING_TYPE_AUDIENCE_GROUP', 'assignedTargetingOptionIds': ['audienceGroup'], }], 'createRequests': [{ 'targetingType': 'TARGETING_TYPE_AUDIENCE_GROUP', 'assignedTargetingOptions': [ {'audienceGroupDetails': updated_audience_group_details} ], }], } # Update the audience targeting response = ( service.advertisers() .lineItems() .bulkEditAssignedTargetingOptions( advertiserId=advertiser_id, body=bulk_edit_request ) .execute() ) # Print the line item IDs the successfully updated. if 'updatedLineItemIds' in response: for id in response['updatedLineItemIds']: print( f'Line Item ID {id} has been updated to target the following ' f'Google Audiences: {added_google_audiences}.' ) # Print the line item IDs that failed to update. if 'failedLineItemIds' in response: for id in response['failedLineItemIds']: print(f'Could not update the audience targeting for Line Item ID {id}') if 'errors' in response: print('The updates failed due to the following errors:') for error in response['errors']: print(f'Error code: {error["code"]}, Message: {error["message"]}')
PHP
// Provide the ID of the parent advertiser. $advertiserId = advertiser-id; // Provide the ID of the line item whose targeting will be updated. $lineItemId = line-item-id; // Provide a list of Google Audience IDs to add to line item targeting. $addedGoogleAudienceIds = array($audienceId); // Build Google audience targeting setting objects to add. $newGoogleAudienceTargetingSettings = array(); foreach ($addedGoogleAudienceIds as $googleAudienceId) { $googleAudienceSetting = new Google_Service_DisplayVideo_GoogleAudienceTargetingSetting(); $googleAudienceSetting->setGoogleAudienceId($googleAudienceId); $newGoogleAudienceTargetingSettings[] = $googleAudienceSetting; } // Build bulk edit request. $bulkEditRequest = new Google_Service_DisplayVideo_BulkEditAssignedTargetingOptionsRequest(); $bulkEditRequest->setLineItemIds(array($lineItemId)); // Call the API, retrieving the existing audience targeting for the // line item. try { $existingAudienceGroupTargetingOption = $this ->service ->advertisers_lineItems_targetingTypes_assignedTargetingOptions ->get( $advertiserId, $lineItemId, AppendAudienceAssignedTargetingOption::AUDIENCE_TARGETING_TYPE, AppendAudienceAssignedTargetingOption::AUDIENCE_TARGETING_OPTION_ID ); $updatedAudienceGroupDetails = $existingAudienceGroupTargetingOption->getAudienceGroupDetails(); $deleteAudienceGroupAssignedTargetingIds = array(AppendAudienceAssignedTargetingOption::AUDIENCE_TARGETING_OPTION_ID); $audienceTargetingDeleteRequest = new Google_Service_DisplayVideo_DeleteAssignedTargetingOptionsRequest(); $audienceTargetingDeleteRequest->setTargetingType(AppendAudienceAssignedTargetingOption::AUDIENCE_TARGETING_TYPE); $audienceTargetingDeleteRequest->setAssignedTargetingOptionIds($deleteAudienceGroupAssignedTargetingIds); $bulkEditRequest->setDeleteRequests(array($audienceTargetingDeleteRequest)); } catch (\Exception $e) { $updatedAudienceGroupDetails = new Google_Service_DisplayVideo_AudienceGroupAssignedTargetingOptionDetails(); } // Build new targeting object with updated list of Google Audience IDs. $updatedIncludedGoogleAudienceGroup = new Google_Service_DisplayVideo_GoogleAudienceGroup(); if (!empty($updatedAudienceGroupDetails->getIncludedGoogleAudienceGroup())) { $updatedIncludedGoogleAudienceGroup ->setSettings( array_merge( $updatedAudienceGroupDetails ->getIncludedGoogleAudienceGroup() ->getSettings(), $newGoogleAudienceTargetingSettings ) ); } else { $updatedIncludedGoogleAudienceGroup->setSettings($newGoogleAudienceTargetingSettings); } $updatedAudienceGroupDetails->setIncludedGoogleAudienceGroup($updatedIncludedGoogleAudienceGroup); $newAudienceAssignedTargetingOption = new Google_Service_DisplayVideo_AssignedTargetingOption(); $newAudienceAssignedTargetingOption->setAudienceGroupDetails($updatedAudienceGroupDetails); $createAudienceTargetingRequest = new Google_Service_DisplayVideo_CreateAssignedTargetingOptionsRequest(); $createAudienceTargetingRequest->setTargetingType(AppendAudienceAssignedTargetingOption::AUDIENCE_TARGETING_TYPE); $createAudienceTargetingRequest->setAssignedTargetingOptions(array($newAudienceAssignedTargetingOption)); $bulkEditRequest->setCreateRequests(array($createAudienceTargetingRequest)); // Call the API, replacing the audience assigned targeting option for the // line item. try { $response = $this ->service ->advertisers_lineItems ->bulkEditAssignedTargetingOptions( $advertiserId, $bulkEditRequest ); } catch (\Exception $e) { $this->renderError($e); return; } // Print information returned by the bulk edit request. // List updated line item IDs. if (empty($response->getUpdatedLineItemIds())) { print '<p>No line items were successfully updated.</p>'; } else { print '<p>The targeting of the following line item IDs were ' . 'updated:</p><ul>'; foreach ($response->getUpdatedLineItemIds() as $id) { printf('<li>%s</li>',$id); } print '</ul>'; } // List line item IDs that failed to update. if (empty($response->getFailedLineItemIds())) { print '<p>No line items failed to update.</p>'; } else { print '<p>The targeting of the following line item IDs failed to ' . 'update:</p><ul>'; foreach ($response->getFailedLineItemIds() as $id) { printf('<li>%s</li>',$id); } print '</ul>'; } // List the errors thrown when the targeting was updated. if (empty($response->getErrors())) { print '<p>No errors were thrown.</p>'; } else { print '<p>The following errors were thrown when attempting to ' . 'update the targeting:</p><ul>'; foreach ($response->getErrors() as $error) { printf( '<li>%s: %s</li>', $error->getCode(), $error->getMessage() ); } print '</ul>'; }
Optymalizowanie kierowania na odbiorców
Dzięki funkcji kierowania zoptymalizowanego Display & Video 360 może rozszerzać zasięg wybranych odbiorców na nowych, odpowiednich użytkowników.
Ustaw kierowanie zoptymalizowane w elemencie zamówienia, korzystając z pola
targetingExpansion w elemencie zamówienia.