Ads Script for Automatic Update Price Extensions

66 views
Skip to first unread message

Michael Erhard

unread,
Sep 13, 2024, 5:42:31 AM9/13/24
to Google Ads Scripts Forum
I made this skript and get this error:  Preiserweiterung hinzugefügt: PRODUCT_CATEGORIES
error
Es ist ein Fehler aufgetreten. Bitte versuchen Sie es später erneut.

This ist my script:

function main() { const spreadsheetId = '1-8UQjl4Z7OWvcpGs'; const sheetName = 'Tabellenblatt1'; // Name des Blattes in deinem Google Sheet const sheet = SpreadsheetApp.openById(spreadsheetId).getSheetByName(sheetName); const data = sheet.getDataRange().getValues(); const priceItems = []; for (let i = 1; i < data.length; i++) { const row = data[i]; const header = row[0]; const description = row[1]; const amount = row[2]; const currencyCode = row[3]; const unitType = row[4]; const finalUrl = row[5]; const mobileFinalUrl = row[6]; if (header && description && amount && currencyCode && unitType && finalUrl && mobileFinalUrl) { try { Logger.log(`Erstelle Preis-Item: Header=${header}, Description=${description}, Amount=${amount}, CurrencyCode=${currencyCode}, UnitType=${unitType}, FinalUrl=${finalUrl}, MobileFinalUrl=${mobileFinalUrl}`); const priceItem = AdsApp.extensions().newPriceItemBuilder() .withHeader(header) .withDescription(description) .withAmount(amount) .withCurrencyCode(currencyCode) .withUnitType(unitType) .withFinalUrl(finalUrl) .withMobileFinalUrl(mobileFinalUrl) .build() .getResult(); if (priceItem) { priceItems.push(priceItem); } else { Logger.log(`Fehler beim Erstellen des Preis-Items für: ${header}`); } } catch (e) { Logger.log(`Fehler beim Erstellen des Preis-Items: ${e.message}`); } } else { Logger.log(`Ungültige Daten in Zeile: ${i + 1}`); } } if (priceItems.length >= 3) { try { Logger.log(`Erstelle Preiserweiterung mit ${priceItems.length} Preis-Items.`); const newPrice = AdsApp.extensions().newPriceBuilder() .withPriceType('PRODUCT_CATEGORIES') .withLanguage('EN') .addPriceItem(priceItems[0]) .addPriceItem(priceItems[1]) .addPriceItem(priceItems[2]) .build() .getResult(); if (newPrice) { const campaignIterator = AdsApp.campaigns() .withCondition('campaign.name = "Smarketer | CH | Brand"') .get(); if (campaignIterator.hasNext()) { const campaign = campaignIterator.next(); campaign.addPrice(newPrice); Logger.log('Preiserweiterung erfolgreich hinzugefügt.'); } else { Logger.log('Keine Kampagne gefunden mit dem Namen "Smarketer | CH | Brand".'); } } else { Logger.log('Fehler beim Erstellen der Preiserweiterung.'); } } catch (e) { Logger.log('Fehler beim Hinzufügen der Preiserweiterung zur Kampagne: ' + e.message); } } else { Logger.log('Mindestens drei Preis-Items werden benötigt, um eine Preiserweiterung zu erstellen.'); } }  

Google Ads Scripts Forum

unread,
Sep 16, 2024, 9:23:59 AM9/16/24
to Google Ads Scripts Forum
Hi,

Thank you for reaching out to the Google Ads Scripts support team.

In order to investigate further on your issue, kindly provide us with the below details.

  • Google Ads account ID/CID
  • Name of the affected script
  • Shareable spreadsheet link if you are using in your script

You can share the requested details via Reply privately to the author option or a direct private reply to this email.

Thanks,
Google Ads scripts team

Michael Erhard

unread,
Sep 16, 2024, 8:32:43 PM9/16/24
to Google Ads Scripts Forum

Michael Erhard

unread,
Sep 17, 2024, 8:36:45 PM9/17/24
to Google Ads Scripts Forum
--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/Oa-RG5NdSRQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/34e703fb-5549-4fa4-aecc-4307e452b417n%40googlegroups.com.

Google Ads Scripts Forum Advisor

unread,
Sep 18, 2024, 5:00:15 AM9/18/24
to adwords...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads Scripts support team.

We are unable to find the CID "693-783-9810". Could you please provide the valid CID where the script "Price Extension" is located? Also, the error screenshots. 

You can share the requested details via Reply privately to the author option or a direct private reply to this email. 

This message is in relation to case "ref:!00D1U01174p.!5004Q02vGICb:ref" (ADR-00268522)

Thanks,
 
Google Logo Google Ads Scripts Team


Reply all
Reply to author
Forward
0 new messages