Real-Time Position Bidding Script

Being able to appear top in the SERP can make all the difference to the success of a campaign, especially when you’re able to anticipate periods of higher competition. Sometimes it can also help to appear lower, depending on your objectives. This script lets you do that!

What’s included?

How does the script work?

This script changes the bids of labelled keywords, so they appear in target positions. It runs every hour, so it always uses up-to-the-minute information about what the auction looks like. You can run multiple instances of the script if you want more updates – even to the point that it’s running every few minutes (although I’d recommend using the API for this).

The changes are limited to 20% of the current bid, and you can set maximum and minimum bids – so you’re still in complete control. You can also get the script to raise keywords to their estimated first page bids when they don’t have impressions, if you want.

Important Note! This script works by changing the bids of keywords. It therefore does not work on keywords that use conversion optimiser or other bidding strategies where the keyword’s CPC bid is overwritten.

Also note that the script assumes that increasing the bid will improve position, and that decreasing the bid will worsen it. This may not be the case for non-exact keywords, as increasing the bid can mean a keyword is eligible for new searches at the bottom of the page. So be careful if using this on broad or phrase match keywords!

How do I use it?

  1. Label your keywords to show what position you want them to be: for example label keywords you want in the top spot as “Position 1.0”. You can use decimals, such as “Position 4.5”, or just an integer like “Position 3”: just make sure the label says ‘position’ followed by a space and a number. Using commas as decimal marks will work here: “Position 4,5” indicates a position of 4.5
  2. Copy the script below. Go to your Google Ads account, into “Bulk operations” and then into “Scripts”. Make a new Script and paste the code in.
  3. Set the options at the top of the code:
    • maxBid stops bids getting too high.
    • minBid stops bids being lowered too much.
    • Set firstPageMaxBid to the highest you think the first page bid should be.
    • dataFile is a name will be used to create a file storing the impressions and average position of the keywords.
    • Set useFirstPageBidsOnKeywordsWithNoImpressions to true to let the script change impressionless keywords’s bids to their first page bid estimate (or the firstPageMaxBid if the first page bid estimate is too high). If set to false, impressionless keywords are ignored.
  4. Save and preview the script (giving authorisation when asked). This will show you the first 100 changes the script will make. If everything looks good, run the script for real!
  5. Create a schedule so that the script runs hourly. This means the script can constantly check new data and keep up with the ever-changing auction landscape.

If you feel up to it, there are some advanced settings too:

By default, the script changes bids by up to 0.2 of their current value: to adjust this, change bidIncreaseProportion (the proportion bids can be increased by) and bidDecreaseProportion (the proportion bids can be decreased by).

The script also allows for a positions being within 0.3 of the target: to adjust this, change targetPositionTolerance.

If you’re having problems with the Script – for example, if it runs for a few seconds and then stops without any changes – then Preview the Script and click on ‘Logs’ to see if there are any messages explaining what happened.

The Real-time Position Bidding script code