リソースを有効にする

デマンド ジェネレーション リソースを作成して構成したら、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']}."
)