最高成效廣告活動選用元件
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
轉換目標
建立最高成效廣告活動時,系統會自動建立一系列與帳戶中CustomerConversionGoal
相符的轉換目標。您可以更新這些資產,為每個最高成效廣告活動量身打造。
如要這麼做,請先擷取所有客戶轉換目標的清單。
const searchResults = AdsApp.search(
`SELECT
customer_conversion_goal.category,
customer_conversion_goal.origin
FROM customer_conversion_goal`
);
接著,您可以逐一查看所有傳回的轉換目標,並為目前的最高成效廣告活動建立更新作業,自訂各目標的指定目標。下列程式碼會將所有關鍵字設為可出價,但您需要自訂這部分邏輯,以符合廣告活動的目標。
執行這段程式碼前,您需要擷取最高成效廣告活動的廣告活動 ID。
建議您在廣告活動建立程序以外的交易中設定轉換目標。CampaignConversionGoalOperation
要求必須將 partialFailure
設為 false
。如果您想在首次建立廣告活動的同一項交易中執行這段程式碼,請務必將整組作業設為停用部分失敗。這個範例程式碼示範如何在個別交易中執行這項作業。
operations = [];
while (searchResults.hasNext()) {
const row = searchResults.next();
const conversionGoal = row.customerConversionGoal;
operations.push({
"campaignConversionGoalOperation": {
"update": {
"resourceName": `customers/${customerId}/campaignConversionGoals/${campaignId}~${conversionGoal.category}~${conversionGoal.origin}`,
// Insert your logic here to determine whether you want this particular
// campaign conversion goal to be biddable or not.
// This code will just default everything to being biddable, but that
// is not necessarily best for your use case.
"biddable": true
},
"updateMask": "biddable"
}
});
}
AdsApp.mutateAll(operations, {partialFailure: false});
廣告活動指定
如要瞭解最高成效廣告活動的指定目標,請務必參閱 API 指南,查看允許的條件類型完整清單。
建立最高成效廣告活動時,不一定要提供額外條件,但根據您的用途,這些條件有助於限制指定目標。下方程式碼範例說明如何設定地理位置目標。如要瞭解其他條件類型的格式,請參閱
CampaignCriterion
說明文件。
您可以建立這些條件,並在對 mutateAll
的相同呼叫中建立廣告活動本身,這個程式碼範例會假設您是以這種方式建構程式碼。
operations.push({
"campaignCriterionOperation": {
"create": {
"campaign": campaignOperation.campaignOperation.create.resourceName,
"negative": false,
"location": {
// 1023191 represents New York City
"geoTargetConstant": "geoTargetConstants/1023191"
}
}
}
});
素材資源群組信號
開始前,請先參閱 API 說明文件,瞭解素材資源群組信號。如要設定這些條件,請將素材資源群組連結至現有的 AudienceInfo
或 SearchThemeInfo
條件。如要改用目標對象,請指定 audience
欄位,而非 searchTheme
欄位,並提供目標對象的資源名稱。
operations.push({
"assetGroupSignalOperation": {
"create": {
"assetGroup": assetGroupOperation.assetGroupOperation.create.resourceName,
"searchTheme": {
"text": "mars cruise"
}
}
}
});
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-27 (世界標準時間)。
[null,null,["上次更新時間:2025-08-27 (世界標準時間)。"],[[["\u003cp\u003ePerformance Max campaigns automatically generate conversion goals based on your existing customer conversion goals, which can be customized for bidding preferences.\u003c/p\u003e\n"],["\u003cp\u003eYou can refine Performance Max campaign targeting by adding criteria like location, though it's not mandatory for campaign creation.\u003c/p\u003e\n"],["\u003cp\u003eAsset group signals can be incorporated into Performance Max campaigns using either audience or search theme information, guiding ad delivery towards relevant user interests.\u003c/p\u003e\n"],["\u003cp\u003eGoogle recommends setting conversion goals in a separate transaction from the rest of the campaign creation process, to ensure smooth execution without partial failures.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the API guide for a complete list of criteria types allowed for campaign targeting and further details on asset group signals and their setup.\u003c/p\u003e\n"]]],[],null,["# Performance Max Optional Components\n\nConversion Goals\n----------------\n\nWhen you create a Performance Max campaign, a series of\n[conversion goals](/google-ads/api/performance-max/conversion-goals)\nare automatically created that match the\n[`CustomerConversionGoal`](/google-ads/api/reference/rpc/CustomerConversionGoal)s in the account. You\ncan customize these specifically for each of your Performance Max campaigns by\nupdating them.\n\nTo do so, first you need to fetch a list of all the customer conversion goals. \n\n const searchResults = AdsApp.search(\n `SELECT\n customer_conversion_goal.category,\n customer_conversion_goal.origin\n FROM customer_conversion_goal`\n );\n\nThen you can iterate through all of the conversion goals you got back and\ncreate an update operation for our current Performance Max campaign to\ncustomize the targeting for each goal. The code below sets all of them to\nbiddable, but you'll want to customize that portion of the logic to match what\nyou want to get out of your campaign.\n\nBefore running this code, you'll need to fetch the campaign ID for your\nPerformance Max campaign.\n\nWe recommend setting up conversion goals in a separate transaction from the\nrest of the campaign creation process.\n[`CampaignConversionGoalOperation`](/google-ads/api/reference/rpc/v21/CampaignConversionGoalOperation)\nrequires that `partialFailure` for the request be set to `false`. If you want\nto run this code in the same transaction where you first make the campaign, you\nmust set the entire set of operations to have partial failure turned off. This\nexample code demonstrates how to perform this operation in a *separate*\ntransaction. \n\n operations = [];\n while (searchResults.hasNext()) {\n const row = searchResults.next();\n const conversionGoal = row.customerConversionGoal;\n\n operations.push({\n \"campaignConversionGoalOperation\": {\n \"update\": {\n \"resourceName\": `customers/${customerId}/campaignConversionGoals/${campaignId}~${conversionGoal.category}~${conversionGoal.origin}`,\n // Insert your logic here to determine whether you want this particular\n // campaign conversion goal to be biddable or not.\n // This code will just default everything to being biddable, but that\n // is not necessarily best for your use case.\n \"biddable\": true\n },\n \"updateMask\": \"biddable\"\n }\n });\n }\n\n AdsApp.mutateAll(operations, {partialFailure: false});\n\nCampaign Targeting\n------------------\n\nFor campaign targeting in Performance Max, make sure to check out the\n[API guide](/google-ads/api/performance-max/create-campaign-criteria) for a\ncomplete list of allowable criteria types.\n\nAdditional criteria are not required to make a Performance Max campaign, but\ncan be useful to help restrict targeting based on your use case. The code\nexample below shows how to set up a geo location target. You can reference the\n[`CampaignCriterion`](/google-ads/api/reference/rpc/v21/CampaignCriterion#criterion) documentation\nfor the format for other criteria types.\n\nYou can create these criteria along with the campaign itself as part of the\nsame call to `mutateAll`, and this code example assumes that that's how you're\nstructuring your code. \n\n operations.push({\n \"campaignCriterionOperation\": {\n \"create\": {\n \"campaign\": campaignOperation.campaignOperation.create.resourceName,\n \"negative\": false,\n \"location\": {\n // 1023191 represents New York City\n \"geoTargetConstant\": \"geoTargetConstants/1023191\"\n }\n }\n }\n });\n\nAsset Group Signals\n-------------------\n\nRead about [asset group signals](/google-ads/api/performance-max/asset-group-signals)\non the API documentation before getting started. These are set up by linking an\nasset group to either an existing [`AudienceInfo`](/google-ads/api/reference/rpc/v21/AudienceInfo)\nor [`SearchThemeInfo`](/google-ads/api/reference/rpc/v21/SearchThemeInfo) criterion. If you want to\nuse an audience instead, specify the `audience` field instead of the\n`searchTheme` field with the audience's resource name. \n\n operations.push({\n \"assetGroupSignalOperation\": {\n \"create\": {\n \"assetGroup\": assetGroupOperation.assetGroupOperation.create.resourceName,\n \"searchTheme\": {\n \"text\": \"mars cruise\"\n }\n }\n }\n });"]]