Script to pause campaigns

63 views
Skip to first unread message

Best Crowdfunding Projects

unread,
Sep 22, 2022, 5:50:45 AM9/22/22
to Google Ads Scripts Forum
I'm trying to make the script that it reads from a Google Sheets and pauses campaigns that we input in that sheet.

This is the code provided in the developers documentation, I just added the spreadsheeturl in const spreadSheet = SpreadsheetApp.openByUrlthe. If I put the spreadsheetURL in the first line it throws an error already.

If I run the code as it is it throws this error:

InputError: Unrecognized function name "main" at l (adsapp_compiled:379:11) at Object.<anonymous> (adsapp_compiled:18977:13)

This is the code I'm running. I tried including only the required columns provided in the campaign template, as well as using the full template and only filling in the data for the corresponding columns 

function bulkUploadFromGoogleSpreadsheet(spreasheetURL) {
  // The format of this spreadsheet should match a valid bulk upload template.
  // See https://developers.google.com/google-ads/scripts/docs/features/bulk-upload
  // for the list of supported bulk upload templates.
  const spreadSheet = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/1eIGM6uGmisyjO9DNAaQJJ52ZQwq9d1ubd4uK2k0U9c8/edit#gid=485045791');
  const sheet = spreadSheet.getActiveSheet();

  const upload = AdsApp.bulkUploads().newFileUpload(sheet);
  upload.forCampaignManagement();

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

Martijn Kraan

unread,
Sep 22, 2022, 10:34:07 AM9/22/22
to Google Ads Scripts Forum
Hi,

I'm not from the official Google Ads Scripts team, but does your have a "main function"?

If not, you can try to call the current function by adding this to the top of your script:

-----------------

function main() {
    bulkUploadFromGoogleSpreadsheet();
}


-----------------

Good luck!
Gr, Martijn
Reply all
Reply to author
Forward
Message has been deleted
0 new messages