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

Need an AdWords Script that adjusts bids by average position

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Looking for a simple AdWords script that will run every x hours or x days and automatically adjust keyword bids based on average position. I'm looking to keep my ads in the #2 spot and want to automate that as much as possible. I also want to be able to put an upper limit on the bid so I don't get too crazy on the spend.

2 Expert replyverified_user

Re: Need an AdWords Script that adjusts bids by average position

Top Contributor
# 2
Top Contributor
Hi Patrick,

I am not sure but may this is what you looking for? https://developers.google.com/adwords/scripts/docs/solutions/bid-to-position

Let us know if this doesn't solve your query.

Thanks
Neha
Neha Gupta, AdWordsTop Contributor Follow Me: My Blog | Twitter | Google+ | LinkedIn
Did you find any helpful responses or answers to your query ? If yes, please mark it as the ‘Best Answer’

Re: Need an AdWords Script that adjusts bids by average position

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
I found this earlier today. The thing that concerns me with this script is that it will be applied to all keywords in an account correct? There are a few campaigns I don't want this applied to. Also, I want to set a maximum bid on some of these as certain campaigns contain keywords that can get awfully spendy.

Re: Need an AdWords Script that adjusts bids by average position

Participant ✭ ✭ ☆
# 4
Participant ✭ ✭ ☆
Hi Patrick,

Have you thought about using automated bidding rules instead? You could set different rules for different campaigns or groups of keyword based upon positions. You can also set maximum bid limits for each rule. You can create up to 100 different rules (not that I would suggest using that many. Smiley Happy)

Rules would also be easier to update and manage in the future, unless you have enough script experience to make adjustments as needed.

Hope this helps!
Amy

Re: Need an AdWords Script that adjusts bids by average position

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Yeah, that's what I'm doing now - and I prefer it - but I have two rules per campaign (raise the big or lower the bid) and 10 campaigns for this one client. I can't seem to simply choose a specific set of campaigns to have one rule run with. I have to do two for each.

The problem is that I'm finding that some of my keywords are not making the cut to be on the first page so I have to go in there every day and bid those up (if reasonable). Others I am fine with not hitting the first page and taking my chances on getting that rare opportunity on. I can't get the rules to run frequent enough to make adjustments to keep some of those bids up or down. Any ideas on that?

Re: Need an AdWords Script that adjusts bids by average position

Participant ✭ ✭ ☆
# 6
Participant ✭ ✭ ☆
Interesting, thanks for the additional context! Can you tell me more about the rules you currently have in place?

Are you using a first-page bid rule? If so that might help a little. Also, if you go to the keyword tab (set on "all campaigns") you can select keywords to be included in the rule. In other words, even if they are in different campaigns, they can be managed by the same rule. This might help cut down the number of rules you have.

Re: Need an AdWords Script that adjusts bids by average position

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
I have two rules for each campaign:
1) If the average position of the keyword is better than 1.25 then lower it by 5%
2) if the average position of the keyword is worse than 3 or 4 then raise it by 20%

I'm shooting to get these keywords to hover around the second slot. The first page rule won't do that. And since I deactivate and activate keywords somewhat regularly just selecting keywords from a filter will cause me to rewrite this rule fairly frequently. There are also 2 out of the 10 campaigns that don't adhere to these rules that I have other rules in place for them since one is buying competitors' names and the QS just sucks so I'm not bidding that up. The other is buying the client's brand so I don't want that anywhere but #1.

To compound things, these campaigns all have different max bids. Some are $4.5, some are $11 so I want to be able to control that by campaign.
Marked as Best Answer.
Solution
Accepted by Theresa_Zook (Top Contributor Alumni)
September 2015

Re: Need an AdWords Script that adjusts bids by average position

Top Contributor
# 8
Top Contributor

Hi Patrick,

 

I use a script like this in many of my Accounts and the easiest solution to the problem of specifying which Campaigns to work upon is to use Labels.  Scripts can test for the existence of certain Labels (or one in a Set of Labels) so it's possible to restrict the action of the script to only those Campaigns you specify by using the condition:

 

.withCondition("LabelNames CONTAINS_ANY ['yourlabel''])

 

For my use, I make bid adjustments based upon the average position over the past 7 days and "Yesterday".  I developed the use of both these ranges to overcome the problem of "over-promoting" a Keyword.  For example, say a Keyword has an average position of #3 for the past 7 days and the script increases it's CPC on Day 1.  On Day 2, it's 7-day average is probably still going to be #3, so the script increases the bid again.  Depending upon the actual bid, and the percentage increase you apply, it's possible that you could apply an increase based upon the 7-day average when in fact the bid is now sufficient to reach #2 on a daily basis, so my script looks at both the 7-day average and "Yesterday", weighting the results of yesterday heavily to try and avoid this.

 

It's also a good idea to use Ad Scheduling and appropriate bid adjustments to compensate for hours of the day when the position changes (given enough data).  For example, your 7-day average might be #2, but you may find that for the hours between 8am and 10am, it's #1.5 and between 4pm and 7pm it's #2.9, so you could use scheduling and bid modifiers to overcome this.

 

The script will take some time to "settle", particularly if you use bid modifiers, but it does work.

 

The full script is below.  PLEASE ensure you PREVIEW the script before running it live and check the Log output for sensible changes.  The logger will output the Keyword, it's current CPC, position and the proposed new CPC.  IF it all looks OK, then schedule the Script to run daily around 1am.

 

Jon

 

// Script to adjust Keyword positions
// (c) Jon Gritton 2014

//max CPC cap
var maxCPC = 8.00;
//min CPC
var minCPC = 0.15;
//percentage change down
var perDown = 0.98;
//percentage change up
var perUp = 1.03;
//target position
var posTarget = 2.0;

function main() {
adjustKeywords();
}

function adjustKeywords() {
var keywordIter = AdWordsApp.keywords()
//.withCondition("CampaignName CONTAINS 'yourtext'") //use this to identify Campaigns
.withCondition("CampaignStatus = 'ENABLED'")
.withCondition("AdGroupStatus = 'ENABLED'")
.withCondition("Status = 'ENABLED'")
//.withCondition("LabelNames CONTAINS_ANY ['yourlabel']") //use if you've applied a Label to Keywords
.forDateRange("LAST_7_DAYS")
.orderBy("Clicks DESC") //ensures good coverage if there's a danger the script will time out
.get();

while (keywordIter.hasNext()) {
var thisKeyword = keywordIter.next();
// Check stats for both last 7 and Yesterday
var statsSeven = thisKeyword.getStatsFor("LAST_7_DAYS");
var kPosSeven=statsSeven.getAveragePosition();
var statsYest = thisKeyword.getStatsFor("YESTERDAY");
var kPosYest=statsYest.getAveragePosition();

if(kPosSeven != 0) { //don't change bids for Keywords without impressions

// If there is no position for yesterday, use last 7, if there is, use
// a calculated average weighted in favour of yesterday. This should
// prevent continued bid changes when previous changes in recent days
// have already had the desired effect.
var kPosFull = (kPosYest == 0) ? kPosSeven : (kPosSeven + (kPosYest * 2))/3;
var kPos = kPosFull.toFixed(2); //set to two decimal places, just for clarity in logging

var currCPC = thisKeyword.getMaxCpc();
var newCPC = currCPC; //just set so newCPC always has a default value;

//Rules - here you can apply your own rules to adjust CPC
//these are very simple

if(kPos > posTarget) {
newCPC = currCPC * perUp;
}

if(kPos < posTarget) {
newCPC = currCPC * perDown;
}

//we always want CPC above lower limit and below upper limit
if(newCPC < minCPC) {newCPC = minCPC;}
if(newCPC > maxCPC) {newCPC = maxCPC;}

newCPC = newCPC.toFixed(2);

Logger.log("KW: " + thisKeyword.getText() + ", CurrCPC: " + currCPC + ", NewCPC: " + newCPC + ", KPos: " + kPos);
thisKeyword.setMaxCpc(newCPC);
}
}
}

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits
Marked as Best Answer.
Solution
Accepted by topic author Patrick Healy
September 2015

Re: Need an AdWords Script that adjusts bids by average position

Participant ✭ ✭ ☆
# 9
Participant ✭ ✭ ☆
Hey Patrick,

If I were you, I would use those two rules and add a third. However, I would set them up by going to the keyword tab, looking at all keywords from all campaigns and then I would filter out the two campaigns that you didn't want to follow the same rules.

From there, I would modify the existing rules to exclude paused keywords.

My rules would look like this:
1) If the average position of the keyword is better than 1.25 and the keyword is active and above the first page bid then lower it by 5%
2) if the average position of the keyword is worse than 3 or 4 and the keyword is active and above the first page bid then raise it by 20%
3) If the keyword is active but below the first page bid then raise it by ___ %

The reason that I subtracted keyword below the first page bid from 1 & 2 is that sometimes a keyword can show as both a high position and below the first page bid. Your rules would be conflicting against each other if you don't exclude it from the earlier rules.

Also, I'm curious as to what your account goals are? Typically if I set up rules, I would put emphasis on CPA and conversion volume. Just curious if those are a factor in your goals or if it is purely impression-oriented in attempt to increase exposure?

Re: Need an AdWords Script that adjusts bids by average position

Visitor ✭ ✭ ✭
# 10
Visitor ✭ ✭ ✭
This client does most of their sales by phone so the goal is really to get exposure, remarketing to drive them back, and drive traffic to strategic pages. CPA, although a sexy metric, isn't practical for this client. I WISH I had a client that sold everything online. I'd be all over that. :-)

This rule structure is really nice. Thanks for this. I wasn't aware I could set a criteria for if the bid was on the first page or not. I is that a different type of rule than I am currently using? I don't see that option.