เปิดใช้งานทรัพยากร

หลังจากสร้างและกําหนดค่าชิ้นงาน Demand Gen แล้ว คุณสามารถอัปเดตentityStatusฟิลด์ENTITY_STATUS_ACTIVEเพื่อเริ่มแสดงโฆษณาได้ แหล่งข้อมูลทั้ง 3 รายการต้องใช้งานอยู่จึงจะเริ่มแสดงโฆษณาได้

ต้องสร้างทรัพยากร LineItem ด้วยสถานะ "ฉบับร่าง" EntityStatus และเปิดใช้งานในคำขอที่ตามมา คุณสร้างทรัพยากร AdGroup และ AdGroupAd ได้ด้วยEntityStatus "ใช้งานอยู่" แต่เราขอแนะนำให้สร้างทรัพยากรเหล่านี้ด้วยสถานะ "หยุดชั่วคราว" วิธีนี้จะช่วยให้คุณกำหนดการกำหนดเป้าหมายและยืนยันการกำหนดค่าที่ถูกต้องได้ก่อนที่จะเปิดใช้งานทรัพยากรในคำขอที่ตามมา

เปิดใช้งานรายการโฆษณา

วิธีเปิดใช้งานรายการโฆษณามีดังนี้

Python

# The ID of the line item's parent advertiser.
advertiser_id = advertiser-id

# The ID of the Demand Gen line item.
line_item_id = line-item-id

line_item_obj = {
    "entityStatus": "ENTITY_STATUS_ACTIVE",
}

# Build and execute request.
response = (
    service.advertisers()
    .lineItems()
    .patch(
        advertiserId=advertiser_id,
        lineItemId=line_item_id,
        updateMask="entityStatus",
        body=line_item_obj,
    )
    .execute()
)

# Display the line item's new entity status
print(
    f"Line item {response['name']} now has entity status "
    f"{response['entityStatus']}."
)

เปิดใช้งานกลุ่มโฆษณา

วิธีเปิดใช้งานกลุ่มโฆษณามีดังนี้

Python

# The ID of the ad group's parent advertiser.
advertiser_id = advertiser-id

# The ID of the Demand Gen ad group.
ad_group_id = ad-group-id

ad_group_obj = {
    "entityStatus": "ENTITY_STATUS_ACTIVE",
}

# Build and execute request.
response = (
    service.advertisers()
    .adGroups()
    .patch(
        advertiserId=advertiser_id,
        adGroupId=ad_group_id,
        updateMask="entityStatus",
        body=ad_group_obj,
    )
    .execute()
)

# Display the ad group's new entity status
print(
    f"Ad group {response['name']} now has entity status "
    f"{response['entityStatus']}."
)

เปิดใช้งานโฆษณา

วิธีเปิดใช้งานโฆษณามีดังนี้

Python

# The ID of the ad's parent advertiser.
advertiser_id = advertiser-id

# The ID of the Demand Gen ad.
ad_id = ad-group-ad-id

ad_obj = {
    "entityStatus": "ENTITY_STATUS_ACTIVE",
}

# Build and execute request.
response = (
    service.advertisers()
    .adGroupAds()
    .patch(
        advertiserId=advertiser_id,
        adGroupAdId=ad_id,
        updateMask="entityStatus",
        body=ad_obj,
    )
    .execute()
)

# Display the ad's new entity status
print(
    f"Ad {response['name']} now has entity status "
    f"{response['entityStatus']}."
)