在 Google Ads API 中,部分訊息欄位會定義為空白訊息物件,例如 campaign.manual_cpm,或者可能只有不需要設定的選用欄位,例如 campaign.manual_cpc。設定這些欄位很重要,因為這樣 API 就能知道要為特定廣告活動使用哪種出價策略,但如果訊息為空白,就無法清楚顯示。
fromgoogle.api_core.protobuf_helpersimportfield_maskcampaign_operation.create=campaigncampaign_operation.update_mask=field_mask(None,campaign)# Here we manually add the "manual_cpm" fieldcampaign_operation.update_mask.append("manual_cpm")
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-03-29 (世界標準時間)。"],[[["Some Google Ads API message fields are defined as empty or only have optional fields, requiring specific handling to indicate the intended bidding strategy."],["To set a bidding strategy using an empty message field (like `manual_cpm`), you need to copy a separate empty instance of the corresponding class onto the campaign object."],["Nested fields within messages (like `campaign.manual_cpc.enhanced_cpc_enabled`) can be updated directly like normal Python object attributes."],["When using empty message objects, ensure the field is added to the request's `update_mask` manually, as the field mask helper cannot automatically detect this."]]],[]]