Bulk uploads across multiple accounts (Client IDs?) taking data from an excel file or google sheet?

149 views
Skip to first unread message

James Bonnet Camacho

unread,
Jan 14, 2015, 2:07:06 PM1/14/15
to adwords...@googlegroups.com
Hey guys,

I've been searching for a way to do a bulk upload (keyword bidding & pausing) across multiple accounts taking data from a single Excel workbook, maybe using Client ID. I really need this feature as most of my day is spent uploading files account by account (40+ accounts). 

Does anyone know if this can be done with AdWords Scripts? If yes, how can I do that (I don't know Java, but I can learn, I only need some guidance).  

Best, James. 

This e-mail and any attachment contains information which is private and confidential and is intended for the addressee only. If you are not an addressee, you are not authorized to read, copy or use the e-mail or any attachment. If you have received this e-mail in error, please notify the sender by return e-mail and then destroy it.

El presente documento electrónico y cualquier anexo al mismo, contiene información confidencial y exclusiva para el destinatario. Si usted no es el destinatario, no está autorizado a leer este documento, a copiarlo o usar el presente y sus anexos o bien si usted ha recibido este documento electrónico por error, favor de notificar al remitente por este mismo conducto y proceda a eliminar de cualquier archivo este documento electrónico

Alexander Wang

unread,
Jan 14, 2015, 3:10:54 PM1/14/15
to adwords...@googlegroups.com
Hi James,

We just announced bulk upload support in scripts this week. We have an overview of the feature as well as some code examples here. As for your particular use case, it's a bit tricky. It's easier if each account processed is a separate file OR a separate sheet in a google spreadsheet. There currently isn't great support in DriveApp for manipulating excel spreadsheets.

You'd want to set up an MCC Script in an MCC account that has access to all of the accounts you'd want to modify. If your spreadsheet(s) was saved in Drive, you could write a script like:

function main() {
 
// Upload spreadsheets for 3 specific accounts and send one email when it's all done.
 
var accounts = MccApp.accounts()
     
.withIds([123,456,789]);
  accounts
.executeInParallel('upload','email');
}

/**
 * Uploads a spreadsheet for an individual account. Assumes spreadsheets are saved
 * as "123456.csv" where 123456 is the id of the account.
 */

function upload() {
 
var account = AdWordsApp.currentAccount();
 
var spreadsheet = DriveApp.getFilesByName(account.getId() + '.csv').next();
 
var upload = AdWordsApp.bulkUploads().newFileUpload(spreadsheet);
  upload
.forCampaignManagement();
  upload
.preview();
}

/**
 * This is an optional callback method that could be used to send an email
 * once the script has completely finished.
 */

function email(results) {
 
var numSuccessful = 0;
 
var numFailed = 0;
 
for (var i = 0; i < results.length; i++) {
   
var status = results[i].getStatus();
   
if (status == 'OK') {
      numSuccessful
++;
   
} else {
      numFailed
++;
   
}
 
}
 
MailApp.sendEmail('us...@example.com','uploads from script complete','Successfully uploaded ' + numSuccessful + ' spreadsheets and failed to upload ' + numFailed + ' spreadsheets.');
}

You would need to adjust the script based on your needs (what the files are called, which accounts to modify, whether an email is necessary, etc).

For more info on how to set up MCC scripts, I recommend looking at the guide. Your specific use case is a bit trickier because I don't see an easy way to access a specific sheet in an excel spreadsheet. If it's converted into a google spreadsheet, it's easier since SpreadsheetApp exposes easy to use methods to access.

If you don't want to manually upload the excel spreadsheet to Drive in order to convert it into google spreadsheet format, you could have it in your Drive and set up a google apps script that would periodically convert it.
The code snippet in comment 15 can be used to convert xlsx files in drive into google spreadsheet files:
(You'd need to enable advanced services for your google apps script).

AdWords Scripts supports advanced services, but unfortunately Drive is not one of them and it looks like converting spreadsheets is not currently supported by DriveApp.

Hope this helps.

Cheers,
Alex

p.s. AdWords scripts uses Javascript not Java. There are some great resources on the web for learning javascript (I think the codecademy one is considered to be pretty good).

James Bonnet Camacho

unread,
Jan 15, 2015, 2:15:13 PM1/15/15
to adwords...@googlegroups.com
Thank you very much, Alex!

What you sent me is perfect, having to use a Google Sheet is not a problem. It's nice to see that I can do my bulk uploads with MCC Scripts.


Reply all
Reply to author
Forward
0 new messages