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

AdWords Automate Location Bid Adjustments to Switch On & Off During the Day

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

Is it possible to do the above?

 

I currently target the UK and want to bid more harshly at lunchtime in London.

 

Can I add a 10% bid adjustment to London during lunchtime hours 11am-2pm only by use of a script?

 

I know that I can have a 10% bid adjustment on London at all times or have a 10% bid adjustment across all locations from 11am - 2pm but I'm wanting to combine the two?

 

At the moment, I'm having to do this manually, and it's easy to forget!!!

 

Thanks

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Rebekah Y
April 2017

Re: AdWords Automate Location Bid Adjustments to Switch On & Off During the Day

[ Edited ]
Top Contributor
# 4
Top Contributor

OK, @Rebekah Y I had some free time so this should do what you want:

 

// Script to adjust location bid at certain times
// (c) Jon Gritton www.cobnut.net 2017

// User Vars
var LOC_NAME = "London"; // the name of the location to affect - check spelling!
var NORM_PERC = 1;  // the normal bid adjustment for the location (1 = 0%)
var ADJUST_PERC = 1.10;  // the adjusted bid, +10% = 1.10
var START_HOUR = 11;  // time to start the adjustment period, 24hr clock
var END_HOUR = 14;  // time to end the adjustment period, 24hr clock

function main() {
  Logger.log("Script starting...");
  var hour = getHour();
  if(hour >= START_HOUR && hour < END_HOUR) {setBid(ADJUST_PERC);}
  if(hour < START_HOUR || hour >= END_HOUR) {setBid(NORM_PERC);}
  Logger.log("Script finished!");
}

function getHour() {
  var now = Utilities.formatDate(new Date(),AdWordsApp.currentAccount().getTimeZone(), 'H');
  Logger.log("This hour:" + now);
  return now;
}
  
function setBid(adj) {
  var theCampaigns = AdWordsApp.campaigns()
    .withCondition("Status = ENABLED")
    .get();
  while(theCampaigns.hasNext()) {
    var thisCampaign = theCampaigns.next();
    var locIter = thisCampaign.targeting()
      .targetedLocations()
      .get();
    while(locIter.hasNext()) {
      var thisLoc = locIter.next();
      if(thisLoc.getName() == LOC_NAME) {
        Logger.log("Campaign: " + thisCampaign.getName());
        thisLoc.setBidModifier(adj);
        Logger.log("Bid Modifier Set to " + adj);
      }
    }
  }
}

As I mentioned, you should schedule this script to run every hour, making sure you save the schedule setting at 1 or 2 minutes past the hour (actual time) so that it runs very shortly after the top of the hour.  You can check the actual time of running from logs once it starts.  The script will adjust the bid every hour but only set the bid adjustment between the hours you set in the variables at the top of the code.  I've coded it this way as it's possible for scripts not to run from time to time and if it was coded to only make two changes a day (one at 11 and one at 14) if either was missed you'd end up either without your boost or have it running all day.  This way if one or two runs are missed the effect is limited.


Please make sure you preview the script before running (you may want to change the hours in the variables so that the bid adjustment is applied) and make sure it does what you expect.  Any problems, let me know.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

View solution in original post

Re: AdWords Automate Location Bid Adjustments to Switch On & Off During the Day

Top Contributor
# 2
Top Contributor

Hi @Rebekah Y that's totally achievable with a fairly simple script, assuming you have London as a specific target within your location targeting settings.  You'd need to set the script to run hourly, and be careful when you set the schedule as scripts run on the minute that the schedule was created (so if set it to run hourly and press "Save" at 16:34, it'll run every hour at 34 minutes past.  Ideally in this case, you'd want to schedule the script at 1 or 2 minutes past the hour so you can get as close as possible to your top of the hour changes.

 

Give a day or so and I'll knock something together for you.  If you don't hear back, just poke me on this thread Smiley Happy

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

AdWords Automate Location Bid Adjustments to Switch On &amp; Off During the Day

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Brill thanks @Jon_Gritton !!!

Marked as Best Answer.
Solution
Accepted by topic author Rebekah Y
April 2017

Re: AdWords Automate Location Bid Adjustments to Switch On &amp; Off During the Day

[ Edited ]
Top Contributor
# 4
Top Contributor

OK, @Rebekah Y I had some free time so this should do what you want:

 

// Script to adjust location bid at certain times
// (c) Jon Gritton www.cobnut.net 2017

// User Vars
var LOC_NAME = "London"; // the name of the location to affect - check spelling!
var NORM_PERC = 1;  // the normal bid adjustment for the location (1 = 0%)
var ADJUST_PERC = 1.10;  // the adjusted bid, +10% = 1.10
var START_HOUR = 11;  // time to start the adjustment period, 24hr clock
var END_HOUR = 14;  // time to end the adjustment period, 24hr clock

function main() {
  Logger.log("Script starting...");
  var hour = getHour();
  if(hour >= START_HOUR && hour < END_HOUR) {setBid(ADJUST_PERC);}
  if(hour < START_HOUR || hour >= END_HOUR) {setBid(NORM_PERC);}
  Logger.log("Script finished!");
}

function getHour() {
  var now = Utilities.formatDate(new Date(),AdWordsApp.currentAccount().getTimeZone(), 'H');
  Logger.log("This hour:" + now);
  return now;
}
  
function setBid(adj) {
  var theCampaigns = AdWordsApp.campaigns()
    .withCondition("Status = ENABLED")
    .get();
  while(theCampaigns.hasNext()) {
    var thisCampaign = theCampaigns.next();
    var locIter = thisCampaign.targeting()
      .targetedLocations()
      .get();
    while(locIter.hasNext()) {
      var thisLoc = locIter.next();
      if(thisLoc.getName() == LOC_NAME) {
        Logger.log("Campaign: " + thisCampaign.getName());
        thisLoc.setBidModifier(adj);
        Logger.log("Bid Modifier Set to " + adj);
      }
    }
  }
}

As I mentioned, you should schedule this script to run every hour, making sure you save the schedule setting at 1 or 2 minutes past the hour (actual time) so that it runs very shortly after the top of the hour.  You can check the actual time of running from logs once it starts.  The script will adjust the bid every hour but only set the bid adjustment between the hours you set in the variables at the top of the code.  I've coded it this way as it's possible for scripts not to run from time to time and if it was coded to only make two changes a day (one at 11 and one at 14) if either was missed you'd end up either without your boost or have it running all day.  This way if one or two runs are missed the effect is limited.


Please make sure you preview the script before running (you may want to change the hours in the variables so that the bid adjustment is applied) and make sure it does what you expect.  Any problems, let me know.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

AdWords Automate Location Bid Adjustments to Switch On &amp; Off During the Day

[ Edited ]
Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Amazing, thanks so much @Jon_Gritton!

How would I amend this to choose a specific campaign name?

And in the future, if I wanted to target say London and Manchester?

 

You're help is very much appreciated!!

Have a good day.

 

Rebekah

AdWords Automate Location Bid Adjustments to Switch On &amp; Off During the Day

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi @Jon_Gritton

Do you happen to have any tips on the above?

Many thanks,

 

Rebekah

Re: AdWords Automate Location Bid Adjustments to Switch On &amp; Off During the Day

Top Contributor
# 7
Top Contributor

Hi @Rebekah Y my apologies, I missed your first post.  I've revised the code to allow you to add as many Campaign Names and/or locations as you want.  The key variables (at the top of the script) are LOC_NAME and CAMP_NAMES; these are now arrays, so if you want to add more, make sure you follow the formatting of the existing code: ["item1","item2","item3"] etc.

 

Try this!

 

// Script to adjust location bid at certain times
// (c) Jon Gritton www.cobnut.net 2017

// User Vars
var LOC_NAME = ["London","Manchester"]; // the names of the location to affect - check spelling!
var CAMP_NAMES = ["Camp1","Camp2"]; // enter your Campaign names here - check spelling!
var NORM_PERC = 1;  // the normal bid adjustment for the location (1 = 0%)
var ADJUST_PERC = 1.10;  // the adjusted bid, +10% = 1.10
var START_HOUR = 11;  // time to start the adjustment period, 24hr clock
var END_HOUR = 14;  // time to end the adjustment period, 24hr clock

function main() {
  Logger.log("Script starting...");
  var hour = getHour();
  if(hour >= START_HOUR && hour < END_HOUR) {setBid(ADJUST_PERC);}
  if(hour < START_HOUR || hour >= END_HOUR) {setBid(NORM_PERC);}
  Logger.log("Script finished!");
}

function getHour() {
  var now = Utilities.formatDate(new Date(),AdWordsApp.currentAccount().getTimeZone(), 'H');
  Logger.log("This hour:" + now);
  return now;
}
  
function setBid(adj) {
  var theCampaigns = AdWordsApp.campaigns()
    //.withCondition("Status = ENABLED")
    .get();
  while(theCampaigns.hasNext()) {
    var thisCampaign = theCampaigns.next();
    if(CAMP_NAMES.indexOf(thisCampaign.getName()) != -1) {
      var locIter = thisCampaign.targeting()
        .targetedLocations()
        .get();
      while(locIter.hasNext()) {
        var thisLoc = locIter.next();
        if(LOC_NAME.indexOf(thisLoc.getName()) != -1) {
          Logger.log("Campaign: " + thisCampaign.getName());
          thisLoc.setBidModifier(adj);
          Logger.log("Bid Modifier Set to " + adj);
        }
      }
    }
  }
}
AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

AdWords Automate Location Bid Adjustments to Switch On &amp; Off During the Day

[ Edited ]
Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭

That's perfect! Thanks so much @Jon_Gritton