Re: Creating campaign from Google Sheet using adwords script

864 views
Skip to first unread message
Message has been deleted

Thea Vega (AdWords Scripts Team)

unread,
Feb 5, 2018, 1:15:39 AM2/5/18
to AdWords Scripts Forum
Hi Thao,

Allow me to re-post your inquiry with personal information (i.e. spreadsheet URL) masked. In the future, please refrain from posting confidential information.

So I wanted to automatically create new campaigns using Google Sheet.
My script is as below:

function main() {
  var SPREADSHEET_URL = 'INSERT_SPREADSHEET_URL_HERE';
  var spreadSheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
  var sheet = spreadSheet.getActiveSheet();

  var upload = AdWordsApp.bulkUploads().newFileUpload(sheet);
  upload.forCampaignManagement();

  // Use upload.apply() to make changes without previewing.
  upload.apply();
}

However, for some reason, after I run the script, nothing happened :/ No error, but also no changes. I have no idea why. Can someone please help?
Thank you,

Thanks,
Thea
AdWords Scripts Team

Thea Vega (AdWords Scripts Team)

unread,
Feb 5, 2018, 1:20:43 AM2/5/18
to AdWords Scripts Forum
Hi Thao,

I checked your script and it seems to be correct. The reason why you are not getting any logs or changes is because:
  • there are no Loggers on your script
  • in bulk uploads, changes made should be seen on Bulk Operation > Bulk uploads page if you used upload.apply(). However, if you use upload.preview(), you will have to approve or reject the changes first before it will be applied to entities you wish to update or create.
Please see this documentation for more details on Bulk Uploads.

Also, I checked your script and it seems that on your spreadsheet, you are missing a couple of fields (i.e. bid strategy type, start date, end date) required to create a new campaign. Please see the list of campaign fields supported in Bulk Uploads as well if those fields are required or not. 

Hope these help.

Thao Pham

unread,
Feb 5, 2018, 4:09:36 AM2/5/18
to AdWords Scripts Forum
Hi Thea,
I added 1 more column (bid strategy), and it seems to work now! 
(it still shows as "No changes", but somehow the campaigns were still created)

Thea Vega (AdWords Scripts Team)

unread,
Feb 5, 2018, 5:01:09 AM2/5/18
to AdWords Scripts Forum
Hi Thao,

Glad that it worked. There were no changes on the changes tab on the script editor because you will only see the changes when using Bulk Uploads in Bulk Operation > Bulk uploads page.

Jack

unread,
Feb 5, 2018, 8:48:13 PM2/5/18
to AdWords Scripts Forum
Hi Thea,

I do have the very same problem, except form the fact I am just looking to add a keyword, no campaign creation


function bulkUploadFromGoogleSpreadsheet() {
  // The format of this spreadsheet should match a valid bulk upload template.
  // for the list of supported bulk upload templates.
  var SPREADSHEET_URL = 'SPREADSHEET_URL';
  var spreadSheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
  var sheet = spreadSheet.getActiveSheet();

  var upload = AdWordsApp.bulkUploads().newFileUpload(sheet);
  upload.forCampaignManagement();

  // Use upload.apply() to make changes without previewing.
  upload.apply();
}


those are the columns of my Google Sheet
ActionCampaign IDCampaignAd group IDAd groupKeywordFinal URL

I had set "add" as action

I am always getting an error when running the script. See attachment.
Also, the Bulk Actions > Uploads section is still empty

Am I missing something?

Thanks

Jack

AW script attachment.JPG

Thao Pham

unread,
Feb 5, 2018, 10:29:38 PM2/5/18
to AdWords Scripts Forum
Is that your whole script?
Did you miss out the main function? What did the error message say?
If it's because of the lack of main function you can try to change the script as below:
function main() {

 
// The format of this spreadsheet should match a valid bulk upload template.
 
// See https://developers.google.com/adwords/scripts/docs/features/bulk-upload
 
// for the list of supported bulk upload templates.
 
var SPREADSHEET_URL = 'SPREADSHEET_URL';
 
var spreadSheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
 
var sheet = spreadSheet.getActiveSheet();


 
var upload = AdWordsApp.bulkUploads().newFileUpload(sheet);
  upload
.forCampaignManagement();


 
// Use upload.apply() to make changes without previewing.
  upload
.apply();
}

Thea Vega (AdWords Scripts Team)

unread,
Feb 6, 2018, 12:48:26 AM2/6/18
to AdWords Scripts Forum
Hi Thao,

Thanks for the information. You may be correct with that one.

Hi Jack,

The script you are using as well as the spreadsheet headers are correct. One possible reason as to why you are having an error is because of what Thao stated. Another possible reason is because the values you have inputted on your spreadsheet is incorrect. For me to investigate further, kindly give me your CID, script name, and spreadsheet access via reply privately to author.

Jack

unread,
Feb 6, 2018, 4:33:49 AM2/6/18
to AdWords Scripts Forum
Thanks so much to both of you!
It seems to be working fine now!

The only change I made was the function main() {  thing

I'm not really sure why it should make a difference, but hey, it works :)

Jack
Reply all
Reply to author
Forward
0 new messages