Fiyatlar
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Fiyat uzantısı oluşturma
function createPrice() {
// For full details on creating a new price item, see:
// https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_priceitembuilder
const priceItem1 = AdsApp.extensions().newPriceItemBuilder()
// Replace the values below with your preferred header, description,
// amount, currency code, unit type, final url, and mobile final url.
.withHeader('header1') // required
.withDescription('description1') // required
.withAmount(1000000) // required
.withCurrencyCode('USD') // required
// Unit type must be one of: 'PER_HOUR', 'PER_DAY', 'PER_WEEK', 'PER_MONTH', 'PER_YEAR',
// or 'PER_NIGHT'
.withUnitType('PER_DAY') // required
.withFinalUrl('https://www.google.com')
.withMobileFinalUrl('https://www.google.com') // required
.build()
.getResult();
const priceItem2 = AdsApp.extensions().newPriceItemBuilder()
// Replace the values below with your preferred header, description,
// amount, currency code, unit type, final url, and mobile final url.
.withHeader('header2') // required
.withDescription('description2') // required
.withAmount(2000000) // required
.withCurrencyCode('USD') // required
// Unit type must be one of: 'PER_HOUR', 'PER_DAY', 'PER_WEEK', 'PER_MONTH', 'PER_YEAR',
// or 'PER_NIGHT'
.withUnitType('PER_HOUR') // required
.withFinalUrl('https://www.google.com') // required
.withMobileFinalUrl('https://www.google.com') // required
.build()
.getResult();
const priceItem3 = AdsApp.extensions().newPriceItemBuilder()
// Replace the values below with your preferred header, description,
// amount, currency code, unit type, final url, and mobile final url.
.withHeader('header3') // required
.withDescription('description3') // required
.withAmount(3000000) // required
.withCurrencyCode('USD') // required
// Unit type must be one of: 'PER_HOUR', 'PER_DAY', 'PER_WEEK', 'PER_MONTH', 'PER_YEAR',
// or 'PER_NIGHT'
.withUnitType('PER_WEEK') // required
.withFinalUrl('https://www.google.com') // required
.withMobileFinalUrl('https://www.google.com') // required
.build()
.getResult();
// For full details on creating a new price extension, see:
// https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder
const newPrice = AdsApp.extensions().newPriceBuilder()
// Replace the values below with your preferred price type, language
// price qualifier, and tracking template
.withPriceType('PRODUCT_CATEGORIES') // required
.withLanguage('EN') // required
// Price qualifier must be one of: 'FROM', 'UP_TO', 'AVERAGE'
.withPriceQualifier('UP_TO') // optional
.withTrackingTemplate('http://www.example.com/track') // optional
.addPriceItem(priceItem1)
.addPriceItem(priceItem2)
.addPriceItem(priceItem3)
.build()
.getResult();
// Add price to a campaign
const campaignIterator = AdsApp.campaigns()
.withCondition('campaign.name = "INSERT_CAMPAIGN_NAME_HERE"')
.get();
if (campaignIterator.hasNext()) {
const campaign = campaignIterator.next();
campaign.addPrice(newPrice);
}
// Add price 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.addPrice(newPrice);
}
// Add price to an account
const account = AdsApp.currentAccount();
account.addPrice(newPrice);
}
Kampanyanın fiyat ayrıntılarını günlüğe kaydet
function logPriceDetails() {
// 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 prices. Retrieving an ad group's and
// account's pricess is similar.
const priceIterator = campaign.extensions().prices().get();
for (const price of priceIterator) {
// 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 = price.getStatsFor('LAST_MONTH');
console.log(`Price extension price qualifier : ${ price.getPriceQualifier() }`);
console.log(`Price extension price type : ${ price.getPriceType() }`);
console.log(`mobile preferred : ${ price.isMobilePreferred() }`);
console.log(`clicks : ${ stats.getClicks() }`);
console.log(`impressions : ${ stats.getImpressions() }`);
console.log('=======');
}
console.log(`${priceIterator.totalNumEntities()} prices in the campaign`);
}
Kampanyadaki fiyatlar için program oluştur
function setPriceSchedule() {
// 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 prices. Retrieving an ad group's and
// account's saitelinks is similar.
const priceIterator = campaign.extensions().prices().get();
for (const price of priceIterator) {
if (price.getPriceType() == 'BRANDS') {
// Set price extension schedule to run only on Mondays and Tuesdays,
// 9 AM to 6 PM. You can follow a similar approach to set schedules for
// other ad extension types.
const monday = {
dayOfWeek: 'MONDAY',
startHour: 9,
startMinute: 0,
endHour: 18,
endMinute: 0
};
const tuesday = {
dayOfWeek: 'TUESDAY',
startHour: 9,
startMinute: 0,
endHour: 18,
endMinute: 0
};
price.setSchedules([monday, tuesday]);
return;
}
}
}
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-08-21 UTC.
[null,null,["Son güncelleme tarihi: 2025-08-21 UTC."],[[["\u003cp\u003eThis script demonstrates how to create price extensions with multiple price items, specifying details like header, description, amount, and currency.\u003c/p\u003e\n"],["\u003cp\u003eIt shows how to add these price extensions to campaigns, ad groups, or accounts for broader or more targeted application.\u003c/p\u003e\n"],["\u003cp\u003eThe script includes functionality to retrieve and log performance data for price extensions, such as clicks and impressions, for specific date ranges.\u003c/p\u003e\n"],["\u003cp\u003eIt provides an example of setting custom schedules for price extensions, allowing them to be active only during specific days and times.\u003c/p\u003e\n"]]],[],null,["# Prices\n\nCreate a price extension\n------------------------\n\n```gdscript\nfunction createPrice() {\n // For full details on creating a new price item, see:\n // https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_priceitembuilder\n const priceItem1 = AdsApp.extensions().newPriceItemBuilder()\n // Replace the values below with your preferred header, description,\n // amount, currency code, unit type, final url, and mobile final url.\n .withHeader('header1') // required\n .withDescription('description1') // required\n .withAmount(1000000) // required\n .withCurrencyCode('USD') // required\n // Unit type must be one of: 'PER_HOUR', 'PER_DAY', 'PER_WEEK', 'PER_MONTH', 'PER_YEAR',\n // or 'PER_NIGHT'\n .withUnitType('PER_DAY') // required\n .withFinalUrl('https://www.google.com')\n .withMobileFinalUrl('https://www.google.com') // required\n .build()\n .getResult();\n\n const priceItem2 = AdsApp.extensions().newPriceItemBuilder()\n // Replace the values below with your preferred header, description,\n // amount, currency code, unit type, final url, and mobile final url.\n .withHeader('header2') // required\n .withDescription('description2') // required\n .withAmount(2000000) // required\n .withCurrencyCode('USD') // required\n // Unit type must be one of: 'PER_HOUR', 'PER_DAY', 'PER_WEEK', 'PER_MONTH', 'PER_YEAR',\n // or 'PER_NIGHT'\n .withUnitType('PER_HOUR') // required\n .withFinalUrl('https://www.google.com') // required\n .withMobileFinalUrl('https://www.google.com') // required\n .build()\n .getResult();\n\n const priceItem3 = AdsApp.extensions().newPriceItemBuilder()\n // Replace the values below with your preferred header, description,\n // amount, currency code, unit type, final url, and mobile final url.\n .withHeader('header3') // required\n .withDescription('description3') // required\n .withAmount(3000000) // required\n .withCurrencyCode('USD') // required\n // Unit type must be one of: 'PER_HOUR', 'PER_DAY', 'PER_WEEK', 'PER_MONTH', 'PER_YEAR',\n // or 'PER_NIGHT'\n .withUnitType('PER_WEEK') // required\n .withFinalUrl('https://www.google.com') // required\n .withMobileFinalUrl('https://www.google.com') // required\n .build()\n .getResult();\n\n // For full details on creating a new price extension, see:\n // https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder\n const newPrice = AdsApp.extensions().newPriceBuilder()\n // Replace the values below with your preferred price type, language\n // price qualifier, and tracking template\n .withPriceType('PRODUCT_CATEGORIES') // required\n .withLanguage('EN') // required\n // Price qualifier must be one of: 'FROM', 'UP_TO', 'AVERAGE'\n .withPriceQualifier('UP_TO') // optional\n .withTrackingTemplate('http://www.example.com/track') // optional\n .addPriceItem(priceItem1)\n .addPriceItem(priceItem2)\n .addPriceItem(priceItem3)\n .build()\n .getResult();\n\n // Add price to a campaign\n const campaignIterator = AdsApp.campaigns()\n .withCondition('campaign.name = \"INSERT_CAMPAIGN_NAME_HERE\"')\n .get();\n if (campaignIterator.hasNext()) {\n const campaign = campaignIterator.next();\n campaign.addPrice(newPrice);\n }\n\n // Add price to an ad group\n const adGroupIterator = AdsApp.adGroups()\n .withCondition('campaign.name = \"INSERT_CAMPAIGN_NAME_HERE\"')\n .withCondition('ad_group.name = \"INSERT_AD_GROUP_NAME_HERE\"')\n .get();\n if (adGroupIterator.hasNext()) {\n const adGroup = adGroupIterator.next();\n adGroup.addPrice(newPrice);\n }\n\n // Add price to an account\n const account = AdsApp.currentAccount();\n account.addPrice(newPrice);\n}\n```\n\nLog price details for a campaign\n--------------------------------\n\n```gdscript\nfunction logPriceDetails() {\n // Get a campaign.\n const campaignIterator = AdsApp.campaigns()\n .withCondition('campaign.name = \"INSERT_CAMPAIGN_NAME_HERE\"')\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error('Campaign not found.');\n }\n const campaign = campaignIterator.next();\n\n // Retrieve the campaign's prices. Retrieving an ad group's and\n // account's pricess is similar.\n const priceIterator = campaign.extensions().prices().get();\n for (const price of priceIterator) {\n // You can also request reports for pre-defined date ranges. See\n // https://developers.google.com/adwords/api/docs/guides/awql,\n // DateRangeLiteral section for possible values.\n const stats = price.getStatsFor('LAST_MONTH');\n\n console.log(`Price extension price qualifier : ${ price.getPriceQualifier() }`);\n console.log(`Price extension price type : ${ price.getPriceType() }`);\n console.log(`mobile preferred : ${ price.isMobilePreferred() }`);\n console.log(`clicks : ${ stats.getClicks() }`);\n console.log(`impressions : ${ stats.getImpressions() }`);\n console.log('=======');\n }\n\n console.log(`${priceIterator.totalNumEntities()} prices in the campaign`);\n}\n```\n\nSet schedule for prices in a campaign\n-------------------------------------\n\n```gdscript\nfunction setPriceSchedule() {\n // Get a campaign.\n const campaignIterator = AdsApp.campaigns()\n .withCondition('campaign.name = \"INSERT_CAMPAIGN_NAME_HERE\"')\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error('Campaign not found.');\n }\n const campaign = campaignIterator.next();\n\n // Retrieve the campaign's prices. Retrieving an ad group's and\n // account's saitelinks is similar.\n const priceIterator = campaign.extensions().prices().get();\n\n for (const price of priceIterator) {\n if (price.getPriceType() == 'BRANDS') {\n // Set price extension schedule to run only on Mondays and Tuesdays,\n // 9 AM to 6 PM. You can follow a similar approach to set schedules for\n // other ad extension types.\n const monday = {\n dayOfWeek: 'MONDAY',\n startHour: 9,\n startMinute: 0,\n endHour: 18,\n endMinute: 0\n };\n\n const tuesday = {\n dayOfWeek: 'TUESDAY',\n startHour: 9,\n startMinute: 0,\n endHour: 18,\n endMinute: 0\n };\n\n price.setSchedules([monday, tuesday]);\n\n return;\n }\n }\n}\n```"]]