4.4 廣告活動管理
簡介
廣告活動建立後,請務必讓商家能夠變更。他們應該可以變更的最關鍵面向如下:
- 預算
- 狀態 (暫停、啟用、移除)
- 指定地理區域 (建議選用)
- 您在廣告活動建立介面加入的任何其他欄位
使用者體驗指南
在總覽頁面和另一個頁面中顯示廣告活動清單,做為廣告活動成效報表的一部分。允許使用者暫停、刪除及編輯廣告活動。
編輯廣告活動後,商家應能修改在建立廣告活動時提供的欄位。可能的呈現方式範例如下:
技術指南
建立零售業專用最高成效廣告活動後,您可以變更下列廣告活動設定:
- 廣告活動名稱
- 廣告活動預算
- 廣告活動狀態
- 廣告活動指定條件
如要查看如何修改資源的詳細總覽,請參閱開發人員指南。您可以透過公開的服務端點變更特定資源 (例如 CampaignService.MutateCampaigns
),或是透過 GoogleAdsService.Mutate
端點使用大量變動功能,在多個不同資源間進行變更。
建議您盡可能大量修改,以減少更新廣告活動所需的作業次數。請記住,您應該使用 GoogleAdsService.Mutate
端點來設計架構,而非使用個別資源端點。這也能讓您日後更輕鬆地擴充功能。
後續範例假設您已將相關 ID 儲存在本機資料庫中。
廣告活動名稱
如要更新廣告活動名稱,您必須修改 Campaign.name
欄位。
且不得包含任何空值 (代碼點 0x0
)、NL 換行 (代碼點 0xA
) 或回車字元 (代碼點 0xD
) 字元。
廣告活動預算
最佳做法是更新現有預算,而非改用新的預算。這樣可以確保廣告活動照常支出費用,且不會導致超量放送。
建議您只更新預算值,不要修改任何其他欄位,提高 DAILY 支出的值。
Python
budget_resource_name = client.get_service(
"CampaignBudgetService"
).campaign_budget_path(customer_id, budget_id)
mutate_operation = client.get_type("MutateOperation")
campaign_budget = mutate_operation.campaign_budget_operation.update
campaign_budget.resource_name = budget_resource_name
# update the budget amount to the new value
campaign_budget.amount_micros = 50000000
client.copy_from(
mutate_operation.campaign_budget_operation.update_mask,
protobuf_helpers.field_mask(None, campaign_budget._pb),
)
return mutate_operation
廣告活動狀態
如要更新廣告活動的狀態 (啟用/暫停/移除),您必須修改 Campaign.status
欄位,並從 CampaignStatus
列舉中指派相關狀態。
您可以在更新廣告活動的程式碼範例中查看變更廣告活動狀態的範例。
廣告活動條件
更新廣告活動條件時,您只需要提供更新使用者所公開條件的功能,可說是指定地理區域的最低數量和指定語言。您可以在更新廣告活動條件出價調節係數的程式碼範例中查看更新廣告活動條件的範例。
如要更新指定地理區域條件,請將 CampaignCriterion.location
更新為新指定地理區域常數的值。
Python
criterion_rname = client.get_service(
"CampaignCriterionService"
).campaign_criterion_path(
customer_id, campaign_id, criterion_id
)
mutate_operation = client.get_type("MutateOperation")
campaign_criterion = mutate_operation.campaign_criterion_operation.update
campaign_criterion.resource_name = criterion_rname
# Set the geo to the update geo targeting
campaign_criterion.location.geo_target_constant = (
geo_target_constant_service.geo_target_constant_path("1022762")
) # Brooklyn
client.copy_from(
mutate_operation.campaign_criterion_operation.update_mask,
protobuf_helpers.field_mask(None, campaign_criterion._pb),
)
return mutate_operation
如要更新指定語言,您需要使用新的語言常數更新 CampaignCriterion.language
值的值。
Python
campaign_criterion_service = client.get_service("CampaignCriterionService")
criterion_rname = campaign_criterion_service.campaign_criterion_path(
customer_id, campaign_id, criterion_id
)
mutate_operation = client.get_type("MutateOperation")
campaign_criterion = mutate_operation.campaign_criterion_operation.update
campaign_criterion.resource_name = criterion_rname
# Set the language to the updated language
# For a list of all language codes, see:
# https://developers.google.com/google-ads/api/data/codes-formats#languages
campaign_criterion.language.language_constant = (
googleads_service.language_constant_path("1000")
) # English
client.copy_from(
mutate_operation.campaign_criterion_operation.update_mask,
protobuf_helpers.field_mask(None, campaign_criterion._pb),
)
return mutate_operation