Posts tagged with google-apps-script

The Script I'm trying to set up uses the MailApp service to send emails to recipients included in a Ghseet.

function sendProcessingEmail() {   var customerId = AdsApp.currentAccount().getCustomerId();   if (config.emailEachRun && config.emailRecipients &&       config.emailRecipients.length) {     MailApp.sendEmail(         config.emailRecipients.join(','),         customerId + ': Link Checker: Checking is ongoing',         'Link checking is still running on account: ' + customerId +             '. For more details see the spreadsheet: ' +             CONFIG_SPREADSHEET_URL);     setDateAsNow('dateEmailed'); 

I have noticed that the Script works fine for emails made out of a combination of numbers and letters but fails to send an email when the address contains other characters. Was wondering if anyone knows a workaround for this? Many thanks in advance.

After exhausting all options, I'm hoping for some help. I am trying to adjust my script to remove all targeted locations for a specific campaign. The problem is, the only way I've found to do it is to iterate through each targeted location and remove them one by one. If a campaign has 2000 location targets, this takes far too long and the script times out.

Below is an example of the standard script used to remove them one by one. Any suggestions on how to speed this up? Is it possible to pass an array of campaign specific locationIDs in and have it remove them all in one shot? Or, is there a function available to remove ALL locations at once? Either of these methods would work for me but I haven't been able to find a solution that accomplishes this.

Thanks in advance for your help

function removeTargetedLocations(campaign) {     var campaignIterator = AdWordsApp.campaigns()         .withCondition('Name = ' + campaign + '')         .get();     if (campaignIterator.hasNext()) {         var campaign = campaignIterator.next();         var locationIterator = campaign.targeting().targetedLocations().get();         while (locationIterator.hasNext()) {             var loc = locationIterator.next();             loc.remove();         }     } } 

I have an ads script which exports data to a sheet based on rules.

However, I only want to replace data within a certain cell range such as 'A2:J' within a Google sheet.

I know how to do this within spreadsheetApp script but unsure/struggling on Ads script/AWQL.

I have pasted the basics of the script below but really could do with insight into whether and how it is possible to push to a specific range.

function main(){ // Put your Google data sheet here var sheetURL = ''; // Enter the tab name here var tabName = ''; var QUERIES = [{'query' : 'SELECT Date, DayOfWeek, HourOfDay, Device, CampaignName, Impressions, Clicks, Cost, Conversions, ConversionValue ' +                         'FROM CAMPAIGN_PERFORMANCE_REPORT ' +             'WHERE Impressions > 0 ' +                       'DURING TODAY',                       //'DURING ' + dateRanges,             'spreadsheetUrl' : sheetURL,             'tabName' : tabName,             'reportVersion' : 'v201809'            }                       ]; //This is to gather the above query and push it to the spreadsheet stated above   for(var i in QUERIES) {     var queryObject = QUERIES[i];     var query = queryObject.query;     var spreadsheetUrl = queryObject.spreadsheetUrl;     var tabName = queryObject.tabName;     var reportVersion = queryObject.reportVersion;     //Logger.log(spreadsheetUrl + " " + query);     var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl);     var sheet = spreadsheet.getSheetByName(tabName);     var report = AdWordsApp.report(query, {apiVersion: reportVersion});     report.exportToSheet(sheet);   } }