Google 搜尋的必要元件

如要從頭產生新的搜尋廣告活動,您至少必須建立下列項目:

廣告活動和預算適用於建立各種廣告活動類型,而廣告群組廣告中的部分設定則特別適合用於建立搜尋廣告活動。請參閱搜尋資產指南,瞭解如何使用指令碼建立資產。

請務必熟悉變動策略,因為本指南只會提供變動中使用的 JavaScript 物件。

預算

預算不得共用,且在帳戶中不得重複。使用 CampaignBudgetOperation 建立預算。

const budgetOperation = {
  "campaignBudgetOperation": {
    "create": {
      "resourceName": `customers/${customerId}/campaignBudgets/${getNextTempId()}`,
      "name": "Search campaign budget",
      "amountMicros": "10000000",
      "deliveryMethod": "STANDARD",
      "explicitlyShared": false
    }
  }
}
operations.push(budgetOperation);

廣告活動

廣告活動必須參照預算,因此您需要上一步建立的確切預算資源名稱,才能找出並使用該特定預算物件。請使用 CampaignOperation。在這個範例中,我們也將 AiMaxSetting 設為啟用 AI Max 搜尋廣告活動,以及 NetworkSettings

const campaignOperation = {
  "campaignOperation": {
    "create": {
      "resourceName": `customers/${customerId}/campaigns/${getNextTempId()}`,
      "name": "Search campaign",
      "status": "PAUSED",
      "advertisingChannelType": "SEARCH",
      "campaignBudget": budgetOperation.campaignBudgetOperation.create.resourceName,
      "biddingStrategyType": "MANUAL_CPC",
      "startDate": "20240314",
      "endDate": "20250313",
      "manualCpc": {
        "enhancedCpcEnabled": true
      },
      "aiMaxSetting": {
        "enableAiMax": true
      },
      "networkSettings": {
        "targetGoogleSearch": true,
        "targetSearchNetwork": true
      },
      "containsEuPoliticalAdvertising": "DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING"
    }
  }
}
operations.push(campaignOperation);

廣告群組

廣告群組必須參照先前建立的廣告活動,因此您需要先前步驟中設定的確切資源名稱,才能識別這個要求中先前建立的廣告活動。您也需要廣告群組本身的暫時 ID,最好將其儲存為新變數,以便在建立關鍵字和廣告群組廣告時使用。使用 AdGroupOperation

const adGroupId = getNextTempId();
const adGroupOperation = {
  "adGroupOperation": {
    "create": {
      "resourceName": `customers/${customerId}/adGroups/${adGroupId}`,
      "name": "Search ad group",
      "status": "PAUSED",
      "campaign": campaignOperation.campaignOperation.create.resourceName,
      "type": "SEARCH_STANDARD"
    }
  }
}
operations.push(adGroupOperation);

關鍵字

您必須使用關鍵字,才能在搜尋結果中觸發廣告。系統會使用 AdGroupCriterionOperation,將這些目標對象新增為廣告群組的條件。您需要參照上一個步驟建立的廣告群組。

const keywordOperation = {
  "adGroupCriterionOperation": {
    "create": {
      "adGroup": adGroupOperation.adGroupOperation.create.resourceName,
      "status": "ENABLED",
      "keyword": {
        "text": "flowers",
        "matchType": "BROAD"
      }
    }
  }
}
operations.push(keywordOperation);

廣告群組廣告 (含廣告)

這個步驟會建立廣告群組廣告,將廣告群組與廣告連結。廣告群組廣告必須參照廣告群組,因此您需要上一個步驟中設定的確切資源名稱。您可以在同一個作業中建立廣告,並使用先前建立的文字素材資源,或在同一個作業中建立文字素材資源。以下範例說明如何使用 ResponsiveSearchAdInfo 建立回應式搜尋廣告。如要使用這項功能,您必須先建立廣告標題和說明的文字素材資源,如「素材資源」指南所示。

如要建立廣告群組廣告,請使用 AdGroupAdOperation

const adGroupAdOperation = {
  "adGroupAdOperation": {
    "create": {
      "resourceName": `customers/${customerId}/adGroupAds/${adGroupId}~${getNextTempId()}`,
      "adGroup": adGroupOperation.adGroupOperation.create.resourceName,
      "status": "PAUSED",
      "ad": {
        "name": "Search RSA ad",
        "finalUrls": [
          "http://www.example.com"
        ],
        "responsiveSearchAd": {
          "headlines": [
            {
              "text": textAsset.assetOperation.create.resourceName
            },
            {
              "text": "Headline 2"
            },
            {
              "text": "Headline 3"
            }
          ],
          "descriptions": [
            {
              "text": "Description 1"
            },
            {
              "text": "Description 2"
            }
          ]
        }
      }
    }
  }
}
operations.push(adGroupAdOperation);