Thursday, July 11, 2013

Set AdParams at the AdGroup Level from a Google Spreadsheet

I've had a few people ask me how to update my previous script about Setting AdParams at the Keyword Level to be able to set them at the AdGroup level. Here is an update to that script that does just that.

To use it, you will need to create a new Google Spreadsheet and load it with the adgroup name, param 1 value, and param 2 value in columns A, B, and C respectively (with column headers). Then copy that url into the script and you should be good to go.


* Update Ad Params by Ad Groups
* Version 1.1
* ChangeLog v1.1
*  - Added the ability to enable param1 or 2 individually
*  - Looks for Keywords on all sheets
*  - Runs much faster
* Created By: Russ Savage
var SET_PARAM1 = true;
var SET_PARAM2 = false;
var DATA_RANGE = 'A:D'; // A - CampaignName, B - AdGroupName, 
                        // C - Param1, D - Param2

function main() {
  var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
  var allSheets = spreadsheet.getSheets();
  var allData = [];
  for(var i in allSheets) {
    var sheet = allSheets[i];
    var data = sheet.getRange(DATA_RANGE).getValues();
    data.shift(); //get rid of headers
    allData = allData.concat(data);
  var allDataHash = {};
  for(var i in allData) {
    var row = allData[i];
    if(row[0] === '') { continue; }
    var rowKey = [row[0],row[1]].join('~~!~~');
    allDataHash[rowKey] = { param1 : row[2], param2: row[3] };
  var kwIter = AdWordsApp.keywords()
    .withCondition('CampaignStatus = ENABLED')
    .withCondition('AdGroupStatus = ENABLED')
    .withCondition('Status = ENABLED')
  while(kwIter.hasNext()) { 
    var kw =;
    var campName = kw.getCampaign().getName();
    var adGroupName = kw.getAdGroup().getName();
    var rowKey = [campName,adGroupName].join('~~!~~');
    if(allDataHash[rowKey]) {
      if(SET_PARAM1) { kw.setAdParam(1, allDataHash[rowKey].param1); }
      if(SET_PARAM2) { kw.setAdParam(2, allDataHash[rowKey].param2); }


  1. The team was ready to begin the project quickly and did more work than expected. UX
    brand agencies team but was ready to communicate professionally with the client about the timeline.

  2. UX design has received regeneration from clients. UX app agency design manages the roof of the new website. UI/UX design appreciated how good the communication was and the way they kept they updated on the status of the project.

  3. The purpose of the Excel application is to allow users to collect like data in a specific location for current and/or future use. Excel spreadsheet expert

  4. Their timeliness, organization, and responsiveness justified the investment and made them a valuable partner.
    UX designers

  5. I am happy to find this post very useful for me, as it contains lot of information.
    David Laid

  6. Wishing you a safe and happy Eid celebration. Dear Bestie, here’s a magical celebration that we’re given to share love and happiness with the rest of the world. eid mubarak wishes for friends

  7. We had a tight schedule, but they complied with the original project plan and covered all tasks on time
    user experience companies

  8. Google Sheets is a very good tool for this human being Google Sheets is a great way to get the most out of your work If you need cheap things If you want to do good shopping, you will need Primary Arms Coupon that's can help you.

  9. The buyer, the vender and the bank sign an understanding, whereby they concur on fundamental archives, terms and other conditions as required to total the bargain, together with any basic breakthroughs along the way. An escrow agent – the bank, acts as an unbiased holder of the money or reports, and in this way keeps the chance of such things as extortion to a least for both parties.