विज्ञापन एक्सटेंशन

Google Ads स्क्रिप्ट में ये विज्ञापन एक्सटेंशन इस्तेमाल किए जा सकते हैं:

विज्ञापन एक्सटेंशन के बारे में ज़्यादा जानने के लिए, सहायता केंद्र पर जाएं.

Google Ads स्क्रिप्ट की मदद से, अपने खाते में काम करने वाले विज्ञापन एक्सटेंशन को ऐक्सेस किया जा सकता है. उदाहरण के लिए, नीचे दिया गया कोड स्निपेट, साइटलिंक को ऐक्सेस करता है:

const sitelinkIterator = AdsApp.extensions().sitelinks().get();
for (const sitelink of sitelinkIterator) {
  // Do something with each sitelink
}

काम करने वाले अन्य विज्ञापन एक्सटेंशन को फिर से ऐक्सेस किया जा सकता है. इसके लिए, संबंधित इटरेटर का इस्तेमाल किया जाता है.

शॉर्ट वीडियो

Google Ads स्क्रिप्ट की मदद से, इस्तेमाल किए जा सकने वाले विज्ञापन एक्सटेंशन बनाए जा सकते हैं. उदाहरण के लिए, नीचे दिया गया कोड स्निपेट, आपके खाते में फ़ोन नंबर बनाने के लिए, फ़ोन नंबर बिल्डर का इस्तेमाल करता है:

const phoneNumberBuilder = AdsApp.extensions().newPhoneNumberBuilder();
const newPhoneNumber = phoneNumberBuilder
  .withCountry("US")
  .withPhoneNumber("6502530000")
  .withCallOnly(false)
  .build()
  .getResult();

जब build() पर कॉल किया जाता है, तो खाते में फ़ोन नंबर बनाया जाता है, लेकिन वह अभी किसी भी विज्ञापन के साथ नहीं दिखेगा. सबसे पहले आपको उसे किसी कैंपेन या विज्ञापन ग्रुप में जोड़ना होगा:

// Add a phone number to a campaign.
campaign.addPhoneNumber(newPhoneNumber);

// Add a phone number to an ad group.
adGroup.addPhoneNumber(newPhoneNumber);

इस्तेमाल किए जा सकने वाले दूसरे विज्ञापन एक्सटेंशन को, कैंपेन या विज्ञापन ग्रुप से जुड़े बिल्डर की तरह ही बनाया और जोड़ा जा सकता है.

आंकड़े पाए जा रहे हैं

Google Ads स्क्रिप्ट की मदद से, खाता, कैंपेन या विज्ञापन ग्रुप के लेवल पर, काम करने वाले विज्ञापन एक्सटेंशन के आंकड़े ऐक्सेस किए जा सकते हैं.

उदाहरण के लिए, साइटलिंक के आंकड़े पाने के लिए:

// Account-level stats
// Get a sitelink in the account.
const sitelinkIterator = AdsApp.extensions().sitelinks().get();
const sitelink = sitelinkIterator.next();
const sitelinkStats = sitelink.getStatsFor("LAST_30_DAYS");
console.log(sitelinkStats.getClicks());

// Campaign-level stats.
// Get a sitelink in a campaign.
const campaignSitelinkIterator = campaign.extensions().sitelinks().get();
const campaignSitelink = campaignSitelinkIterator.next();
const campaignSitelinkStats = campaignSitelink.getStatsFor("LAST_30_DAYS");
console.log(campaignSitelinkStats.getClicks());

// Ad-group-level stats.
// Get a sitelink in an ad group.
const adGroupSitelinkIterator = adGroup.extensions().sitelinks().get();
const adGroupSitelink = adGroupSitelinkIterator.next();
const adGroupSitelinkStats = adGroupSitelink.getStatsFor("LAST_30_DAYS");
console.log(adGroupSitelinkStats.getClicks());

इसी तरह, अन्य विज्ञापन एक्सटेंशन के आंकड़ों को भी ऐक्सेस किया जा सकता है.

विज्ञापन एक्सटेंशन में बदलाव करना

Google Ads स्क्रिप्ट की मदद से, काम करने वाले मौजूदा विज्ञापन एक्सटेंशन में बदलाव किए जा सकते हैं. उदाहरण के लिए, नीचे दिया गया कोड स्निपेट मौजूदा साइटलिंक में बदलाव करेगा:

// Get a sitelink in the account.
const sitelinkIterator = AdsApp.extensions().sitelinks().get();
const sitelink = sitelinkIterator.next();
console.log(sitelink.getLinkText()); // "original text"

// Get a sitelink from a campaign. Assume it's the same one as above.
const campaignSitelinkIterator = campaign.extensions().sitelinks().get();
const campaignSitelink = campaignSitelinkIterator.next();
console.log(campaignSitelink.getLinkText()); // "original text"

// Get a sitelink from an ad group. Assume it's the same one as above.
const adGroupSitelinkIterator = adGroup.extensions().sitelinks().get();
const adGroupSitelink = adGroupSitelinkIterator.next();
console.log(adGroupSitelink.getLinkText()); // "original text"

// Change the sitelink's link text. This change will affect all the campaigns
// and ad groups to which the sitelink belongs.
campaignSitelink.setLinkText("new link text");

// Same text!
console.log(campaignSitelink.getLinkText()); // "new link text"
console.log(adGroupSitelink.getLinkText()); // "new link text"
console.log(sitelink.getLinkText()); // "new link text"

यही सिद्धांत अन्य समर्थित विज्ञापन एक्सटेंशन पर लागू होते हैं.

विज्ञापन-ग्रुप-लेवल के विज्ञापन एक्सटेंशन ऐक्सेस करना

Google Ads स्क्रिप्ट की मदद से, विज्ञापन ग्रुप-लेवल के विज्ञापन एक्सटेंशन ऐक्सेस किए जा सकते हैं. नीचे दिए गए तरीके से कॉल करने पर, वे फ़ोन नंबर दिखेंगे जिन्हें किसी विज्ञापन ग्रुप में साफ़ तौर पर जोड़ा गया है. ध्यान दें कि अगर उस कैंपेन में फ़ोन नंबर जोड़े गए हैं जिससे वह विज्ञापन समूह जुड़ा है, तो नीचे दिए गए तरीके से कॉल करने पर वे नहीं दिखेंगे. भले ही, वे फ़ोन नंबर उस विज्ञापन समूह से दिखाए जाने वाले विज्ञापनों पर दिखाए जाने की शर्तें पूरी करते हों.

// This will return phone numbers that have been explicitly added to this
// ad group.
const adGroupPhoneNumberIterator = adGroup.extensions().phoneNumbers().get();

इसी तरह, विज्ञापन ग्रुप लेवल पर अन्य विज्ञापन एक्सटेंशन भी ऐक्सेस किए जा सकते हैं.

खाता-स्तरीय विज्ञापन एक्सटेंशन ऐक्सेस करना

Google Ads स्क्रिप्ट की मदद से, खाता-लेवल के विज्ञापन एक्सटेंशन को ऐक्सेस किया जा सकता है. कॉलआउट, मोबाइल ऐप्लिकेशन, और समीक्षाओं को खाता-लेवल के विज्ञापन एक्सटेंशन के तौर पर जोड़ा जा सकता है, लेकिन खाता-लेवल पर साइटलिंक और फ़ोन नंबर उपलब्ध नहीं हैं. नीचे दिए गए तरीके से, आपको ऐसे कॉलआउट दिखेंगे जिन्हें आपके खाते में साफ़ तौर पर जोड़ा गया है.

// This will return callouts that have been explicitly added to your account.
const accountCalloutIterator =
    AdsApp.currentAccount().extensions().callouts().get();

खाता-लेवल के मोबाइल ऐप्लिकेशन और समीक्षाओं को इसी तरह से ऐक्सेस किया जा सकता है.

खाता-स्तरीय विज्ञापन एक्सटेंशन जोड़ना अभियान-स्तरीय या विज्ञापन-समूह-स्तरीय विज्ञापन एक्सटेंशन जोड़ने जैसा ही है. नीचे दिए गए उदाहरण में, खाता-लेवल पर कॉलआउट एक्सटेंशन जोड़ने का तरीका बताया गया है:

// Create a new callout in the account. Without adding the new callout as an ad
// group, campaign or account extension, it won't actually serve.
const calloutBuilder = AdsApp.extensions().newCalloutBuilder();
const newCallout = calloutBuilder.withText("Sample Text").build().getResult();

// Add the new callout as an account-level extension. This enables it to serve
// for all campaigns in the account.
AdsApp.currentAccount().addCallout(newCallout);

इसी तरह, खाता-लेवल के मोबाइल ऐप्लिकेशन और समीक्षाएं भी जोड़ी जा सकती हैं.

अभियान, विज्ञापन समूह और खाता विज्ञापन एक्सटेंशन निकाले जा रहे हैं

इस्तेमाल किए जा सकने वाले विज्ञापन एक्सटेंशन को खाता लेवल पर, कैंपेन और विज्ञापन ग्रुप से हटाया जा सकता है. Google Ads स्क्रिप्ट का इस्तेमाल करके, किसी खाते से विज्ञापन एक्सटेंशन को एक साथ नहीं हटाया जा सकता.

// Get a mobile app from a campaign.
const campaignMobileAppIterator = campaign.extensions().mobileApps().get();
const campaignMobileApp = campaignMobileAppIterator.next();

// Remove the mobile app.
campaign.removeMobileApp(campaignMobileApp);

// The mobile app still exists in the account and will be returned in the
// following iterator.
const mobileAppIterator = AdsApp.extensions().mobileApps().get();

इसी तरह, किसी विज्ञापन-ग्रुप-लेवल या खाता-लेवल के मोबाइल ऐप्लिकेशन को हटाने के लिए:

// Get a mobile app from an ad group.
const adGroupMobileAppIterator = adGroup.extensions().mobileApps().get();
const adGroupMobileApp = adGroupMobileAppIterator.next();

// Remove the mobile app.
adGroup.removeMobileApp(adGroupMobileApp);

// Get an account-level mobile app.
const accountMobileAppIterator =
    AdsApp.currentAccount().extensions().mobileApps().get();
const accountMobileApp = accountMobileAppIterator.next();

// Remove the mobile app.
// Note that this removes the mobile app from the account level, so it will
// not serve as an account-level extension, but it will still exist in the
// account. It can still be added to an AdGroup or Campaign, or again as an
// account-level extension in the future.
AdsApp.currentAccount().removeMobileApp(accountMobileApp);

अगर किसी अभियान से सभी मोबाइल ऐप्लिकेशन निकाल दिए जाते हैं, तो अभियान में मोबाइल ऐप्लिकेशन एक्सटेंशन नहीं रहेगा. अपने अभियान से सभी मोबाइल ऐप्लिकेशन निकालने के लिए, आपको उस अभियान के लिए मोबाइल ऐप्लिकेशन की सूची फिर से हासिल करनी होगी और उन्हें एक-एक करके हटाना होगा. यह प्रक्रिया अन्य समर्थित विज्ञापन एक्सटेंशन के लिए समान है.