Callout
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Creare un'estensione callout
function createCallout() {
// For full details on creating a new callout extension, see:
// https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_calloutbuilder
const newCallout = AdsApp.extensions().newCalloutBuilder()
// Replace the values below with your text, and mobile preferred
.withText('Free Shipping') // required
.withMobilePreferred(true) // optional
.build()
.getResult();
// Add callout to a campaign
const campaignIterator = AdsApp.campaigns()
.withCondition('campaign.name = "INSERT_CAMPAIGN_NAME_HERE"')
.get();
if (campaignIterator.hasNext()) {
const campaign = campaignIterator.next();
campaign.addCallout(newCallout);
}
// Add callout 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.addCallout(newCallout);
}
// Add callout to an account
const account = AdsApp.currentAccount();
account.addCallout(newCallout);
}
Registrare i dettagli dei callout per una campagna
function logCalloutDetails() {
// 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 callouts. Retrieving an ad group's and
// account's calloutss is similar.
const calloutIterator = campaign.extensions().callouts().get();
for (const callout of calloutIterator) {
// 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 = callout.getStatsFor('LAST_MONTH');
console.log(`Callout text : ${ callout.getText() }`);
console.log(`mobile preferred : ${ callout.isMobilePreferred() }`);
console.log(`clicks : ${ stats.getClicks() }`);
console.log(`impressions : ${ stats.getImpressions() }`);
console.log('=======');
}
console.log(`${calloutIterator.totalNumEntities()} callouts in the campaign`);
}
Imposta la pianificazione per i callout in una campagna
function setCalloutSchedule() {
// 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 callouts. Retrieving an ad group's and
// account's saitelinks is similar.
const calloutIterator = campaign.extensions().callouts().get();
for (const callout of calloutIterator) {
if (callout.getText() == 'Free Shipping') {
// Set callout 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
};
callout.setSchedules([monday, tuesday]);
return;
}
}
}
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2024-08-21 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2024-08-21 UTC."],[[["This script provides functions for creating, analyzing, and scheduling Google Ads callout extensions."],["`createCallout()` demonstrates how to generate a new callout and associate it with a campaign, ad group, or account."],["`logCalloutDetails()` retrieves and displays performance metrics for callouts within a specified campaign."],["`setCalloutSchedule()` enables scheduling callouts to run on specific days and times, illustrated with a Monday-Tuesday, 9 AM-6 PM example."]]],[]]