AdWords
1.9K members online now
1.9K members online now
Improve your AdWords performance and boost your ROI, CTR, and Quality Score
Guide Me
star_border
Reply

Help with param script

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi Guys, 

 

I'm using the script bellow to update ads in Google Adwords via a Google spreadsheet using params. My account is quite large and every new campaign I add with param-ads does not get changed via the script. I get the "Cannot fetch more AdWords entities from iterator: exceeded limit of 50000." So I need help in modifying the script bellow so it reaches all my campaigns with params and not reaches the limit. Is this possible? I'm new to this so it would be nice of you if you could show me were to make changes in the script? Or even help me by inserting the changes. 

 

Thanks!

 

Script:

 

 

var SPREADSHEET_URL = "PUT YOUR SPREADSHEET URL HERE";
var SET_PARAM1 = true;
var SET_PARAM2 = true;
var DATA_RANGE = 'ASmiley Very Happy'; // 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')
    .get();
   
  while(kwIter.hasNext()) {
    var kw = kwIter.next();
    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); }
    }
  }
}

Re: Help with param script

Participant ✭ ✭ ✭
# 2
Participant ✭ ✭ ✭
Hi Dan,

Jon (@Cobnut) has given a very elegant solution to the problem you are experiencing on the exact same script that you are using.

See this article:
https://www.en.adwords-community.com/t5/Advanced-Features/how-can-i-turn-around-a-script-limit/m-p/3...

Hope that helps

Re: Help with param script

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi, Thanks for your reply!

Yes, I know but I don't get the script to work properly. Need more help :/

Re: Help with param script

Explorer ✭ ✭ ✭
# 4
Explorer ✭ ✭ ✭

Hi Dan H,

 

A single iterator can handle of maximum of 50,000 entries. Since your account is large enough, you can split them into smaller chunks. Like, iterating all campaigns first then the ad groups and keywords in batches.

 

 

Your current script is like this : 

 

 

Spoiler
var kwIter = AdWordsApp.keywords()
   
.withCondition('CampaignStatus = ENABLED')
   
.withCondition('AdGroupStatus = ENABLED')
   
.withCondition('Status = ENABLED')
   
.get();

 

 

 

You can change that to like this, for solving this problem,

 

 

Spoiler
var campaigns = AdWordsApp.campaigns().withCondition('CampaignStatus=ENABLED').get();
 
while (campaigns.hasNext()) {
   
var campaign = campaigns.next();
   
var adGroups = campaign.adGroups().withCondition("AdGroupStatus=ENABLED").get();
   
while (adGroups.hasNext()) {
     
var adGroup = adGroups.next();
     
     
var kwIter = adGroup.keywords()

   
.withCondition('Status = ENABLED')
   
.get();
   
}
 
}

 

 

Hope this will solve your problem Smiley Happy

Thanks!

Shafi Ahamed

 

 

Re: Help with param script

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Hi Shafi,

thanks for your help, I tried replacing that part of the code, but when I run the script with these changes it just says "No changes or logs". It does not do anything..