Aktywowanie zasobów

Po utworzeniu i skonfigurowaniu komponentów kampanii generującej popyt możesz zaktualizować ich entityStatuspolaENTITY_STATUS_ACTIVE, aby rozpocząć wyświetlanie reklam. Aby zacząć wyświetlać reklamy, wszystkie 3 zasoby muszą być aktywne.

Zasoby LineItem muszą być tworzone ze stanem „draft”EntityStatus i aktywowane w kolejnej prośbie. Zasoby AdGroupAdGroupAd można utworzyć ze stanem „aktywny” EntityStatus, ale zalecamy tworzenie tych zasobów ze stanem „wstrzymany”. Dzięki temu możesz przypisać kierowanie i sprawdzić prawidłową konfigurację przed aktywowaniem zasobów w kolejnych żądaniach.

Aktywowanie elementu zamówienia

Aby aktywować element zamówienia:

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

Aktywowanie grupy reklam

Aby aktywować grupę reklam:

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

Aktywowanie reklamy

Aby aktywować reklamę:

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