電話號碼
透過集合功能整理內容 你可以依據偏好儲存及分類內容。
建立來電額外資訊
function createPhoneNumber() { // For full details on creating a new call extension, see: // https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_phonenumberbuilder const newPhoneNumber = AdsApp.extensions().newPhoneNumberBuilder() // Replace the values below with your link country and phone number .withCountry('US') .withPhoneNumber('INSERT_PHONE_NUMBER_HERE') .build() .getResult(); // Add phone number to a campaign const campaignIterator = AdsApp.campaigns() .withCondition('campaign.name = "INSERT_CAMPAIGN_NAME_HERE"') .get(); if (campaignIterator.hasNext()) { const campaign = campaignIterator.next(); campaign.addPhoneNumber(newPhoneNumber); } // Add phone number to an ad group const adGroupIterator = AdsApp.adGroups() .withCondition('campaign.name = "INSERT_CAMPAIGN_NAME_HERE"') .withCondition('ad_group.name = "INSERT_AD_GROUP_NAME_HERE"') .get(); if (adGroupIterator.hasNext()) { const adGroup = adGroupIterator.next(); adGroup.addPhoneNumber(newPhoneNumber); } }
記錄廣告活動的電話號碼詳情
function logPhoneNumberDetails() { // Get a campaign. const campaignIterator = AdsApp.campaigns() .withCondition('campaign.name = "INSERT_CAMPAIGN_NAME_HERE"') .get(); if (!campaignIterator.hasNext()) { throw new Error('Campaign not found.'); } const campaign = campaignIterator.next(); // Retrieve the campaign's phone numbers. Retrieving an ad group's and // account's phone number extensions is similar. const phoneNumberIterator = campaign.extensions().phoneNumbers().get(); for (const phoneNumber of phoneNumberIterator) { // You can also request reports for pre-defined date ranges. See // https://developers.google.com/adwords/api/docs/guides/awql, // DateRangeLiteral section for possible values. const stats = phoneNumber.getStatsFor('LAST_MONTH'); console.log(`Phone number : ${ phoneNumber.getPhoneNumber() }`); console.log(`clicks : ${ stats.getClicks() }`); console.log(`impressions : ${ stats.getImpressions() }`); console.log('======='); } console.log(`${phoneNumberIterator.totalNumEntities()} phone number extensions in the campaign`); }
為廣告活動中的來電額外資訊設定時段
function setPhoneNumberSchedule() { // Get a campaign. const campaignIterator = AdsApp.campaigns() .withCondition('campaign.name = "INSERT_CAMPAIGN_NAME_HERE"') .get(); if (!campaignIterator.hasNext()) { throw new Error('Campaign not found.'); } const campaign = campaignIterator.next(); // Retrieve the campaign's phone numbers. Retrieving an ad group's and // account's phone number extensions is similar. const phoneNumberIterator = campaign.extensions().phoneNumbers().get(); for (const phoneNumber of phoneNumberIterator) { if (phoneNumber.getPhoneNumber() === 'INSERT_PHONE_NUMBER_HERE') { // Set phone number schedule to run only on Mondays and Tuesdays, 9 AM to // 6 PM. const monday = { dayOfWeek: 'MONDAY', startHour: 9, startMinute: 0, endHour: 18, endMinute: 0 }; const tuesday = { dayOfWeek: 'TUESDAY', startHour: 9, startMinute: 0, endHour: 18, endMinute: 0 }; phoneNumber.setSchedules([monday, tuesday]); break; } } }
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-28 (世界標準時間)。
[[["容易理解","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-07-28 (世界標準時間)。"],[[["This script demonstrates how to create and manage call extensions in Google Ads, including adding them to campaigns and ad groups."],["It provides functionality to retrieve and log key performance metrics like clicks and impressions for call extensions within a specific campaign for the last month."],["The script also illustrates how to set custom schedules for call extensions, controlling the days and times they are active."],["Example code shows how to configure a call extension to run only on Mondays and Tuesdays between 9 AM and 6 PM."]]],[]]