Automating Campaign Creation

59 views
Skip to first unread message

Karl

unread,
Aug 12, 2019, 2:12:09 PM8/12/19
to Google Ads Scripts Forum
I found that it's possible to automate campaign creation for search campaigns only using Google Ads script. I'm interested in using csv upload. 
I have a few questions: 

1) How can I automate shopping campaign creation? Or at least some parts of shopping campaign creation?

2) Is it possible to automate campaign creation on MCC level?

Thank you

Google Ads Scripts Forum Advisor Prod

unread,
Aug 12, 2019, 4:07:00 PM8/12/19
to adwords-scripts+apn2wqe8nukpgabq...@googlegroups.com, adwords-scripts+apn2wqe8nukpgabq...@googlegroups.co, adwords...@googlegroups.com
Hi Karl,

Scripts does not support shopping campaign creation at the moment. Please follow our blog for any relevant updates on this front. 

For creating search, display or video campaigns in bulk with scripts, I would recommend using bulk uploads, which can be used in conjunction with ad manager level scripts.

Regards,
Matt
Google Ads Scripts Team

ref:_00D1U1174p._5001UEImJu:ref

Michael Ramsey

unread,
Aug 13, 2019, 8:43:48 AM8/13/19
to Google Ads Scripts Forum
Hi Karl,

I have done this. There are a few ins and outs. You are correct you need to use the CSV upload feature to accomplish this. There's no reason it can't be done at the MCC level. 

The main issue I ran into is that the script does not wait for the CSV upload to complete. You need to wait for it to finish if you want to work with the created campaign after. Also validating the CSV based campaign creation requires some trial and error before it's ready to be done at scale. 

This is how I'm doing it in one of the scripts - using an initial utilities.sleep() call to wait a little bit. 

  // Create campaign via bulk upload because apparently this just isn't a regular supported function?
  function createCampaign(campaignName, startDate, endDate) {
    // Specify standard columns
    // TbD: Start date, End date (YYYY-MM-DD) - also extract location taregeting or set in sheet?
    var columns = ["Campaign", "Budget", "Budget type", "Status", "Bid Strategy type", "Campaign type", 
                    "start date", "end date"];

    var upload = AdsApp.bulkUploads().newCsvUpload(columns);

    // Add in values for campaign to be created
    upload.append({
      'Campaign': campaignName,
      'Budget': 0.5,
      'Budget type': 'Daily',
      'Status': 'Paused',
      'Bid Strategy type': 'Maximize clicks',
      'Campaign type': 'Search',
      'start date': startDate,
      'end date': endDate
    });

    // Make the campaign
    upload.forCampaignManagement();
    upload.apply();

    // Wait a little bit because apparently the upload application is not actually instant
    Utilities.sleep(500);
  }

However, sometimes this isn't a long enough wait.

So when I'm creating the campaign I also do this when calling the function above:

// Check if this campaign already exists. If not create it and assign it to the iterator
            var campaignIterator = AdsApp.campaigns().withCondition('Name = "' + currentCampaign + '"').get();
            if (campaignIterator.totalNumEntities() == 0) {
              createCampaign(currentCampaign, row[44], row[45]);

              campaignIterator = AdsApp.campaigns().withCondition('Name = "' + currentCampaign + '"').get();

              // Stupid workaround for delay in campaign deployment just keeps trying until it gets the campaign
              var fail = 0;
              while (campaignIterator.totalNumEntities() == 0) {
                Utilities.sleep(500);
                campaignIterator = AdsApp.campaigns().withCondition('Name = "' + currentCampaign + '"').get();
                fail++;
                if (fail > 10) {
                  // waited 5 seconds and still failing?
                  throw '5 seconds of campaign not appearing';
                }
              }

              // Get the active campaign to work with it
              var campaign = campaignIterator.next();

This will catch if there is an error in the CSV upload and the campaign isn't generated, but you'll have to go in and download the error log for the CSV upload operation to figure out what went wrong.
Reply all
Reply to author
Forward
0 new messages