กำหนดการกำหนดเป้าหมาย

การแสดงโฆษณา Demand Gen จะควบคุมโดยใช้การกำหนดเป้าหมายที่กำหนดให้กับพาร์ทเนอร์หลัก ผู้ลงโฆษณา รายการโฆษณา และกลุ่มโฆษณา

ใช้การกำหนดเป้าหมายที่กำหนดให้กับรายการบรรทัด Demand Gen และกลุ่มโฆษณาเพื่อเข้าถึง ลูกค้าที่เหมาะกับธุรกิจและปรับปรุงประสิทธิภาพของแคมเปญ

เลือกตำแหน่งที่จะกำหนดการกำหนดเป้าหมาย

คุณกำหนดการกำหนดเป้าหมายได้ทั้งรายการโฆษณา Demand Gen และกลุ่มโฆษณา

กำหนดการกำหนดเป้าหมายให้กับรายการโฆษณา Demand Gen หากต้องการให้การกำหนดเป้าหมายมีผลกับ โฆษณาทั้งหมดที่แสดงภายใต้รายการโฆษณานั้น ไม่เช่นนั้น ให้กําหนดการกําหนดเป้าหมายให้กับกลุ่มโฆษณาแต่ละกลุ่ม

การรองรับการกำหนดเป้าหมายตามประเภทชิ้นงาน Demand Gen

ทรัพยากรแต่ละประเภทรองรับการกำหนดเป้าหมายบางประเภท

ต่อไปนี้คือรายการประเภทการกำหนดเป้าหมายที่รายการโฆษณา Demand Gen รองรับ

  • TARGETING_TYPE_CARRIER_AND_ISP
  • TARGETING_TYPE_DAY_AND_TIME
  • TARGETING_TYPE_DEVICE_MAKE_MODEL
  • TARGETING_TYPE_DEVICE_TYPE
  • TARGETING_TYPE_GEO_REGION
  • TARGETING_TYPE_KEYWORD
  • TARGETING_TYPE_LANGUAGE
  • TARGETING_TYPE_NEGATIVE_KEYWORD_LIST
  • TARGETING_TYPE_OPERATING_SYSTEM
  • TARGETING_TYPE_POI

ต่อไปนี้คือรายการประเภทการกำหนดเป้าหมายที่กลุ่มโฆษณา Demand Gen รองรับ

  • TARGETING_TYPE_AGE_RANGE
  • TARGETING_TYPE_APP
  • TARGETING_TYPE_APP_CATEGORY
  • TARGETING_TYPE_AUDIENCE_GROUP
  • TARGETING_TYPE_CATEGORY
  • TARGETING_TYPE_GENDER
  • TARGETING_TYPE_GEO_REGION
  • TARGETING_TYPE_HOUSEHOLD_INCOME
  • TARGETING_TYPE_KEYWORD
  • TARGETING_TYPE_LANGUAGE
  • TARGETING_TYPE_PARENTAL_STATUS
  • TARGETING_TYPE_URL
  • TARGETING_TYPE_YOUTUBE_CHANNEL
  • TARGETING_TYPE_YOUTUBE_VIDEO

การรองรับ TARGETING_TYPE_GEO_REGION, TARGETING_TYPE_POI และ TARGETING_TYPE_LANGUAGE จะขึ้นอยู่กับการตั้งค่าของฟิลด์ demandGenSettings.geoLanguageTargetingEnabled ในทรัพยากร LineItem ระดับบน หากฟิลด์เป็นจริง จะกำหนดการกำหนดเป้าหมายตามสถานที่และภาษาได้เฉพาะกับรายการโฆษณาระดับบนสุดเท่านั้น หากฟิลด์เป็นเท็จ การกำหนดเป้าหมายนี้จะกำหนดให้กับกลุ่มโฆษณาแต่ละกลุ่มได้เท่านั้น

ค้นหาตัวเลือกการกำหนดเป้าหมายที่ใช้ได้

ระบบจะระบุการกำหนดเป้าหมายตามประเภท ระบุตัวเลือกการกำหนดเป้าหมายโดยใช้วิธีใดวิธีหนึ่งต่อไปนี้

ดึงข้อมูลการกำหนดเป้าหมายที่มีอยู่

การกำหนดเป้าหมายที่มีอยู่จะจำกัดการกำหนดเป้าหมายที่เพิ่มลงในรายการโฆษณาหรือกลุ่มโฆษณาได้

รายการโฆษณาและกลุ่มโฆษณา Demand Gen จะแสดงเฉพาะ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.")