Script: Set up Google Ads Campaigns Directly from Google Doc
Posted on 11/16/2023
Reviewed by Arnt Eriksen updated at 8/14/2024
Introduction
Setting up Google Ads Search campaigns is a very time consuming task. Unlike Smart campaigns it requires a lot of time and efforts. For many years, we struggled with Excel and Google Ads editor. It was very frustrating to spend hours on repeatable tasks which should be automated.
Our developers wrote a solution which enables you to upload new campaigns directly from Google Doc. Such a relief. Now it’s a matter of several minutes to set up new campaigns and upload them using SKAG structure.
Why SKAG?
Relevance is a key success factor in Google Ads. Being relevant has been rewarded with higher quality scores and as a result, a lower cost per click.
SKAG means “single keyword per ad group,” meaning in each of your ad groups you are using only one keyword.
In order to build relevant Google Ads campaigns, you should be able to add separate ad copies for each of your target keywords. This can be achieved by only using the SKAG structure. With SKAG you can:
- Create separate, relevant ads for each of your target keywords
- Create additional extensions for each of your keywords
- Set target CPA bids individually for each keyword on an ad group level
We have been using this structure in all of our accounts for years and it has turned out to be very easy to manage. At first it might seem to be a bit too complicate. But you will love SKAG and immediately see how sexy is it!
Now, let’s go through the steps to set up your Google Ads campaign.
Step 1. Prepare Google doc with target keywords
- Make a copy of this template
- Paste the list of your target keywords and ads
- If you need to create more than 2 campaigns add additional tabs.
Step 2. Upload campaigns
Navigate to Bulk Operations > Scripts
To add a script from MMC level copy and paste the following code:
function main(){ var mccAccount = AdWordsApp.currentAccount('644-558-2469'); var accountID = '443-484-0665'; // Don't forget to change! var childAccounts = MccApp.accounts().withIds([accountID]).get(); var childAccount = childAccounts.next(); MccApp.select(childAccount); var SPREADSHEET_ID = '1PLc2IHf2YYeo_O9dSEldN4Jq4s9CXaBynuNHfHWlPXQ'; //Don't forget to change! var ss = SpreadsheetApp.openById(SPREADSHEET_ID); SpreadsheetApp.setActiveSpreadsheet(ss); var sheets = ss.getSheets(); var columnsCampaign = [ 'Campaign', 'Budget', 'Bid Strategy type', 'Campaign type', 'Campaign subtype' ]; var columnsAdgroups = ['Campaign', 'Ad group', 'Bid Strategy type', 'Default max. CPC'//, 'Ad', 'Description line 1', 'Description line 2', 'Description line 2', 'Display URL', 'Final URL' ]; var columnsKeywords = ['Campaign', 'Ad group', 'Keyword' ]; var columnsAds = ['Campaign', 'Ad group', 'Headline 1', 'Headline 2', 'Description', 'Path 1', 'Path 2', 'Final URL' ]; var uploadCampaign = AdWordsApp.bulkUploads().newCsvUpload( columnsCampaign, {moneyInMicros: false}); var uploadAdgroup = AdWordsApp.bulkUploads().newCsvUpload( columnsAdgroups, {moneyInMicros: false}); var uploadKeyword = AdWordsApp.bulkUploads().newCsvUpload( columnsKeywords, {moneyInMicros: false}); var uploadAds = AdWordsApp.bulkUploads().newCsvUpload( columnsAds, {moneyInMicros: false}); //adding BMM campaigns for (var sheetNum = 0; sheetNum < sheets.length; sheetNum++){ SpreadsheetApp.setActiveSheet(sheets[sheetNum]); var campaign = SpreadsheetApp.getActiveSheet().getName() + " BMM"; uploadCampaign.append({ 'Campaign': campaign, 'Budget': 1, 'Bid Strategy type': 'cpc', 'Campaign type': 'Search Only', 'Campaign subtype' : 'All features' }); var values = SpreadsheetApp.getActiveSheet().getRange('A2:A').getValues(); var values2 = SpreadsheetApp.getActiveSheet().getRange('B2:G').getValues(); outer: for (var i = 0; i < values.length; i++) { var adgroup = values[i][0].toString().trim(); if (adgroup != '') { uploadAdgroup.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Bid Strategy type': 'cpc', 'Default max. CPC' : 1 }); var keyword = "+" + adgroup.replace(/ /g, ' +') uploadKeyword.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Keyword': keyword }); //Logger.log(keyword); for (var k = 0; k < values2.length; k++) { var adHead1 = values2[k][0].toString().trim(); var adHead2 = values2[k][1].toString().trim(); var adDescr = values2[k][2].toString().trim(); var path1 = values2[k][3].toString().trim(); var path2 = values2[k][4].toString().trim(); var finalURL = values2[k][5].toString().trim(); if (adHead1 != ''){ uploadAds.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Headline 1': adHead1, 'Headline 2': adHead2, 'Description': adDescr, 'Path 1': path1, 'Path 2': path2, 'Final URL' : finalURL }); } else continue outer; //Logger.log([campaign,adgroup,adHead,adDescr1,adDescr2,displURL,finalURL]); } } } } //Adding Exact Campaigns for (var sheetNum = 0; sheetNum < sheets.length; sheetNum++){ SpreadsheetApp.setActiveSheet(sheets[sheetNum]); var campaign = SpreadsheetApp.getActiveSheet().getName() + " Exact"; uploadCampaign.append({ 'Campaign': campaign, 'Budget': 1, 'Bid Strategy type': 'cpc', 'Campaign type': 'Search Only', 'Campaign subtype' : 'All features' }); var values = SpreadsheetApp.getActiveSheet().getRange('A2:A').getValues(); var values2 = SpreadsheetApp.getActiveSheet().getRange('B2:G').getValues(); outer: for (var i = 0; i < values.length; i++) { var adgroup = values[i][0].toString().trim(); if (adgroup != '') { uploadAdgroup.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Bid Strategy type': 'cpc', 'Default max. CPC' : 1 }); var keyword = '[' + adgroup + ']'; uploadKeyword.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Keyword': keyword }); for (var k = 0; k < values2.length; k++) { var adHead1 = values2[k][0].toString().trim(); var adHead2 = values2[k][1].toString().trim(); var adDescr = values2[k][2].toString().trim(); var path1 = values2[k][3].toString().trim(); var path2 = values2[k][4].toString().trim(); var finalURL = values2[k][5].toString().trim(); if (adHead1 != ''){ uploadAds.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Headline 1': adHead1, 'Headline 2': adHead2, 'Description': adDescr, 'Path 1': path1, 'Path 2': path2, 'Final URL' : finalURL }); } else continue outer; //Logger.log([campaign,values[i][0],values2[k][0],values2[k][4]]); } } //Logger.log([campaign,values[i][0],values2[0][0],values2[0][4]]); } } uploadCampaign.forCampaignManagement(); uploadAdgroup.forCampaignManagement(); uploadKeyword.forCampaignManagement(); uploadAds.forCampaignManagement(); uploadCampaign.apply(); Utilities.sleep(5000); uploadAdgroup.apply(); Utilities.sleep(5000); uploadAds.apply(); Utilities.sleep(5000); uploadKeyword.apply(); }
To add code directly from your AdWords account use this code:
function main(){ var SPREADSHEET_ID = '1PLc2IHf2YYeo_O9dSEldN4Jq4s9CXaBynuNHfHWlPXQ'; //Don't forget to change! var ss = SpreadsheetApp.openById(SPREADSHEET_ID); SpreadsheetApp.setActiveSpreadsheet(ss); var sheets = ss.getSheets(); var columnsCampaign = [ 'Campaign', 'Budget', 'Bid Strategy type', 'Campaign type', 'Campaign subtype' ]; var columnsAdgroups = ['Campaign', 'Ad group', 'Bid Strategy type', 'Default max. CPC'//, 'Ad', 'Description line 1', 'Description line 2', 'Description line 2', 'Display URL', 'Final URL' ]; var columnsKeywords = ['Campaign', 'Ad group', 'Keyword' ]; var columnsAds = ['Campaign', 'Ad group', 'Headline 1', 'Headline 2', 'Description', 'Path 1', 'Path 2', 'Final URL' ]; var uploadCampaign = AdWordsApp.bulkUploads().newCsvUpload( columnsCampaign, {moneyInMicros: false}); var uploadAdgroup = AdWordsApp.bulkUploads().newCsvUpload( columnsAdgroups, {moneyInMicros: false}); var uploadKeyword = AdWordsApp.bulkUploads().newCsvUpload( columnsKeywords, {moneyInMicros: false}); var uploadAds = AdWordsApp.bulkUploads().newCsvUpload( columnsAds, {moneyInMicros: false}); //adding BMM campaigns for (var sheetNum = 0; sheetNum < sheets.length; sheetNum++){ SpreadsheetApp.setActiveSheet(sheets[sheetNum]); var campaign = SpreadsheetApp.getActiveSheet().getName() + " BMM"; uploadCampaign.append({ 'Campaign': campaign, 'Budget': 1, 'Bid Strategy type': 'cpc', 'Campaign type': 'Search Only', 'Campaign subtype' : 'All features' }); var values = SpreadsheetApp.getActiveSheet().getRange('A2:A').getValues(); var values2 = SpreadsheetApp.getActiveSheet().getRange('B2:G').getValues(); outer: for (var i = 0; i < values.length; i++) { var adgroup = values[i][0].toString().trim(); if (adgroup != '') { uploadAdgroup.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Bid Strategy type': 'cpc', 'Default max. CPC' : 1 }); var keyword = "+" + adgroup.replace(/ /g, ' +') uploadKeyword.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Keyword': keyword }); //Logger.log(keyword); for (var k = 0; k < values2.length; k++) { var adHead1 = values2[k][0].toString().trim(); var adHead2 = values2[k][1].toString().trim(); var adDescr = values2[k][2].toString().trim(); var path1 = values2[k][3].toString().trim(); var path2 = values2[k][4].toString().trim(); var finalURL = values2[k][5].toString().trim(); if (adHead1 != ''){ uploadAds.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Headline 1': adHead1, 'Headline 2': adHead2, 'Description': adDescr, 'Path 1': path1, 'Path 2': path2, 'Final URL' : finalURL }); } else continue outer; //Logger.log([campaign,adgroup,adHead,adDescr1,adDescr2,displURL,finalURL]); } } } } //Adding Exact Campaigns for (var sheetNum = 0; sheetNum < sheets.length; sheetNum++){ SpreadsheetApp.setActiveSheet(sheets[sheetNum]); var campaign = SpreadsheetApp.getActiveSheet().getName() + " Exact"; uploadCampaign.append({ 'Campaign': campaign, 'Budget': 1, 'Bid Strategy type': 'cpc', 'Campaign type': 'Search Only', 'Campaign subtype' : 'All features' }); var values = SpreadsheetApp.getActiveSheet().getRange('A2:A').getValues(); var values2 = SpreadsheetApp.getActiveSheet().getRange('B2:G').getValues(); outer: for (var i = 0; i < values.length; i++) { var adgroup = values[i][0].toString().trim(); if (adgroup != '') { uploadAdgroup.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Bid Strategy type': 'cpc', 'Default max. CPC' : 1 }); var keyword = '[' + adgroup + ']'; uploadKeyword.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Keyword': keyword }); for (var k = 0; k < values2.length; k++) { var adHead1 = values2[k][0].toString().trim(); var adHead2 = values2[k][1].toString().trim(); var adDescr = values2[k][2].toString().trim(); var path1 = values2[k][3].toString().trim(); var path2 = values2[k][4].toString().trim(); var finalURL = values2[k][5].toString().trim(); if (adHead1 != ''){ uploadAds.append({ 'Campaign': campaign, 'Ad group': adgroup, 'Headline 1': adHead1, 'Headline 2': adHead2, 'Description': adDescr, 'Path 1': path1, 'Path 2': path2, 'Final URL' : finalURL }); } else continue outer; //Logger.log([campaign,values[i][0],values2[k][0],values2[k][4]]); } } //Logger.log([campaign,values[i][0],values2[0][0],values2[0][4]]); } } uploadCampaign.forCampaignManagement(); uploadAdgroup.forCampaignManagement(); uploadKeyword.forCampaignManagement(); uploadAds.forCampaignManagement(); uploadCampaign.apply(); Utilities.sleep(5000); uploadAdgroup.apply(); Utilities.sleep(5000); uploadAds.apply(); Utilities.sleep(5000); uploadKeyword.apply(); }
Step 3. Preview and run the script
Step 4.Wait for 5 mins and check your new campaigns!
There is also a premium version of this script available so that you can create a separate ad for each of your ad groups using Ad generator. To get its demo feel free to contact us.