Kích hoạt tài nguyên

Sau khi tạo và định cấu hình tài nguyên Tạo nhu cầu, bạn có thể cập nhật các trường entityStatus thành ENTITY_STATUS_ACTIVE để bắt đầu phân phát quảng cáo. Cả ba tài nguyên đều phải ở trạng thái đang hoạt động thì mới bắt đầu phân phát quảng cáo.

LineItem tài nguyên phải được tạo bằng "draft" EntityStatus và kích hoạt trong một yêu cầu tiếp theo. Bạn có thể tạo tài nguyên AdGroupAdGroupAd bằng "active" EntityStatus (đang hoạt động), nhưng bạn nên tạo các tài nguyên này ở trạng thái "paused" (tạm dừng). Bằng cách đó, bạn có thể chỉ định tiêu chí nhắm mục tiêu và xác minh cấu hình chính xác trước khi kích hoạt các tài nguyên trong các yêu cầu tiếp theo.

Kích hoạt chi tiết đơn hàng

Sau đây là cách kích hoạt chi tiết đơn hàng:

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']}."
)

Kích hoạt nhóm quảng cáo

Sau đây là cách kích hoạt nhóm quảng cáo:

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']}."
)

Kích hoạt quảng cáo

Sau đây là cách kích hoạt quảng cáo:

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']}."
)