AdWords
6.5K members online now
For issues or questions regarding logging in, account access, or account security
Guide Me
star_border
Reply

System error - no Logging's working

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi there, 
I' ve recently got an system-error on one of my adwords scripts, I just made a few changes last time and now it isn't running anymore. It just stops after ~10 seconds with an system error and there are no further error messages. It isn't outputting any Logger information either, I'm stuck here, anyone had this problem before?
thanks for any help,

Julian

1 Expert replyverified_user

System error - no Logging's working

Top Contributor
# 2
Top Contributor

Hi Julian
Are you still experiencing this issue?
Would you care to share the script so I can test it?

Re: System error - no Logging's working

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
That's my Code, what I want to do is:
1. get Data of a Spreadsheet and generate Adgroups & Keywords from it!
I have to correct myself, the script completes after 1 second, but there are no Logger-Outputs or created Keywords/Ads. It seems like it is just doing nothing at all!
Thanks for your help.

function main() { var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl); Logger.log(spreadsheet.getUrl()); //Import der CSV-Datei wird hier über ein GoogleSpreadsheet-Trigger gehandelt, dieser läuft täglich um 8:00 Uhr morgens var array = readObjects(spreadsheet.getUrl()); //für alle for (var key in array) { var object = array[key]; Logger.log(object); var adGroupName = getAdGroupOrCreate(campaignName, object.adGroupName, object); createKeywords(campaignName ,adGroupName, object.text, object.text2); createTextAd(campaignName ,adGroupName, object); } Logger.log(spreadsheet.getUrl()); } function checkForCharacter(string){ var maxLength = 30; if (string.length > 30) { var cuttedString = string.substring(0,maxLength) } return cuttedString; } function createKeywords(campaignName, adGroupName, customLabel1, customLabel2) { var campaignIter = AdWordsApp.campaigns().withCondition('Name = "' + campaignName + '"').get(); Logger.log('Anzahl an Kampagnen (Keywords)' + campaignIter.totalNumEntities()); if (campaignIter.hasNext()) { var campaign = campaignIter.next(); var adGroupIterator = campaign.adGroups().withCondition('Name = "' + replaceSonderzeichen(quote(adGroupName)) + '"').get(); Logger.log('Anzahl an AdGroups (Keywords): ' + adGroupIterator.totalNumEntities()); if (adGroupIterator.hasNext()) { Logger.log("in IF"); var adGroup = adGroupIterator.next(); var keywordIterator = adGroup.keywords().withCondition('Text = "' + replaceSonderzeichen(quote(customLabel1)) + '"' || 'Text = "' + replaceSonderzeichen(quote(customLabel2)) + '"').get(); Logger.log('Anzahl an Keywords (Keywords)' + keywordIterator.totalNumEntities()); if (!keywordIterator.hasNext()) { var keywordOperation1 = adGroup.newKeywordBuilder() .withText('"'+replaceSonderzeichen(quote(customLabel1))+'"') .withCpc(0.7) .build(); if (!keywordOperation1.isSuccessful()){ Logger.log('Errors from Keyword: ' + keywordOperation1.getErrors()); } var keyword = keywordOperation1.getResult(); var keywordOperation2 = adGroup.newKeywordBuilder() .withText('"'+replaceSonderzeichen(quote(customLabel2))+'"') .withCpc(0.7) .build(); if (!keywordOperation2.isSuccessful()){ Logger.log('Errors from Keyword: ' + keywordOperation2.getErrors()); } var keyword2 = keywordOperation2.getResult(); } } } } function readObjects(url) { var objectsByName = {}; var spreadsheet = SpreadsheetApp.openByUrl(url); var sheet = spreadsheet.getSheets()[0]; var data = sheet.getRange(2,1, sheet.getLastRow(), sheet.getLastColumn()).getValues(); for (var i = 0; i < data.length; i++) { if(data[i][0]){ var object = { headline1: data[i][2] + " " + data[i][3], headline2: data[i][13] + "€" + " au lieu de " + data[i][12] + "€", description: "En stock. Livraison rapide, 100 jours retour gratuit.", finalURL: data[i][6], text: data[i][2] + " " + data[i][3], text2: data[i][2] + " " + data[i][3] + " " + data[i][4], //text3: data[i][2] + " " + data[i][3] + " promo", link: data[i][6], brand: data[i][2], titel: data[i][3], productType: data[i][4], color: data[i][5], price: data[i][12], pfad1: data[i][2], adGroupName: data[i][2] + " " + data[i][0], //Streichpreis: data[i][6], //quantity: data[i][7], //productScore: data[i][8], Geschlecht: data[i][21], id: data[i][0] }; objectsByName[object.headline1] = object; //objectsByName.push(object); } } return objectsByName; } function getAdGroupOrCreate(campaignName, adGroupName, object) { var campaignIter = AdWordsApp.campaigns().withCondition('Name = "' + campaignName + '"').get(); Logger.log(campaignIter.totalNumEntities()); if (campaignIter.hasNext()) { var campaign = campaignIter.next(); var adGroupIterator = campaign.adGroups().withCondition('Name = "' + replaceSonderzeichen(quote(adGroupName)) + '"').get(); Logger.log('total NumEntities of adGroupIterator '+adGroupIterator.totalNumEntities()); Logger.log(adGroupIterator.hasNext()); if (adGroupIterator.hasNext()) { var adGroup = adGroupIterator.next(); Logger.log('adGroupName: '+adGroup.getName()); Logger.log('CampaignName: '+adGroup.getCampaign()); return adGroup.getName(); } else { //create adGroup var adGroupBuilder = campaign.newAdGroupBuilder(); var adGroupOperation = adGroupBuilder .withName(replaceSonderzeichen(quote(object.adGroupName))) .withStatus("ENABLED") .build(); var adGroup = adGroupOperation.getResult(); Logger.log('createdAdGroupName: '+adGroup.getName()); Logger.log('createdAdGroupCampaignName: '+ adGroup.getCampaign()); return adGroup.getName(); } } } function createTextAd(campaignName, adGroupName, object) { var campaignIter = AdWordsApp.campaigns().withCondition('Name = "' + campaignName + '"').get(); Logger.log('Anzahl an Kampagnen (TextAd)' + campaignIter.totalNumEntities()); if (campaignIter.hasNext()) { var campaign = campaignIter.next(); var adGroupIterator = campaign.adGroups().withCondition('Name = "' + replaceSonderzeichen(quote(adGroupName)) + '"').get(); Logger.log('Anzahl an AdGroups (TextAd): ' + adGroupIterator.totalNumEntities()); if (adGroupIterator.hasNext()) { var adGroup = adGroupIterator.next(); var adIterator = adGroup.ads().withCondition('HeadlinePart1 CONTAINS_IGNORE_CASE "' + replaceSonderzeichen(quote(object.headline1)) + '"').get(); Logger.log('Anzahl an Ads (TextAds): ' + adIterator.totalNumEntities()); Logger.log('CreateTextAd******** '+!adIterator.hasNext()) if (!adIterator.hasNext()) { var adOperation = adGroup.newAd().expandedTextAdBuilder() .withHeadlinePart1(replaceSonderzeichen(quote(object.headline1))) .withHeadlinePart2(replaceSonderzeichen(quote(object.headline2))) .withDescription(object.description) .withPath1(object.pfad1) .withFinalUrl(object.finalURL) .build(); if (!adOperation.isSuccessful()) { Logger.log("Errors from adOperation: " + adOperation.getErrors()); } var ad = adOperation.getResult(); } } } } function quote(str){ var stringfixed = str.replace(/"/g,"\'"); return stringfixed; } function replaceSonderzeichen(string){ return string.replace(/[@,%*!'°]/g, ""); } function replaceKomma(string) { return string.replace(/,/g,"\."); } function replaceSonderZeichenKeywords(string) { return string.replace(/,!@%^*()={};~`<>?/g,""); }

System error - no Logging's working

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

And I'm using this script for other Feeds to create Keywords & Ads aswell, there it's working fine.