Google Adwords dynamic prices with Ad params

It is possible in Google Adwords to update your ads with parameters. These parameters can contain numbers, valuta’s and more. Instead of updating your ads over and over again manually every time your stock or product prices are changing, you could automate this with an Adwords Script. This makes updating your ad copy child’s play.

Unfortunately, it isn’t possible to use words in your parameters (valuta signs like $ and € are allowed). Besides of that, you don’t lose historical data anymore and it’s no longer necessary to approve your ads by Google.

Some examples

  • Automatically updating your product prices.
  • Show up-to-date temperature’s in ads for flight destinations.
  • Someone is searching for ice-skates in Groningen, show them the ice thickness in mm.
  • Show the actual exchange rates for bitcoins or other valuta’s for currency exchanges.
  • Show the number of products sold or the number of available.

How to use

In my example we are going to update our product price in our ad description.

Step 1

Put one or more parameters in your ad description or ad title.

Schermafbeelding 2015-10-03 om 10.50.52

For parameter 1 use:

And if you would like to use a second parameter set:

Our script is going to scrape the destination url of the ad. If there’s the information found we need, we are going to update the ad parameter. If the information we need doesn’t exist, the ad shows up our fallback value.

Step 2

The maximum execution time of an Google Adwords script is 30 minutes. To avoid our script is running out of time we could define the campaigns we would like to affect. The best way to do this is defining the campaign Id’s of the campaigns instead of using campaign names (that are likely to change at a later moment). We could find the campaign Id’s by adding this column at the campaign report tab.  Select Campaign Id at the modify column section.

Schermafbeelding 2015-10-03 om 10.18.39

In this case the Campaign Id is 126900143.

Schermafbeelding 2015-10-03 om 10.20.32

Step 3

Open the script libary.

Schermafbeelding 2015-10-03 om 11.04.40

Add the script in the Google Adwords interface and authorize it.

Schermafbeelding 2015-10-03 om 11.32.34

And allow the script to manage your account. For unexplained reasons sometimes you have to do this twice :SSchermafbeelding 2015-10-03 om 11.34.08

Add this script. We have to change it a bit to make it fit into your setup.

Step 4

We have to change line 1. Here we could give up our campaign Id’s.

In case of one campaign Id:

In case of multiple campaign Id’s:

Step 5

This is the most difficult step. First we are going to explore our source code. Go to the destination url of your ad and open te source code (Right click somewhere on the page and click on Show source code). Look in the source code for the line that is representing your product price. In my case it is:


Now we have to find the right regular expression to scrape the desired information from our destination url. A regular expression can be used to find our information based on a pattern from the source code of our destination url. I am using this line for parameter 1:

This retrieves anything like this from our source code.

Another example could be:

This retrieves anything that looks like this from our source code.

Because this part is different for any of those, my advise is to ask a developer to take a look over your shoulder.

Next steps are removing unwanted code that’s retrieved by the regular expression and format our found information. By replacing unwanted html with nothing we finally get our goal.

You have to keep trying. Run some previews and read the logs to find out everything is working properly.

Ask me for help in the comments if you get stuck.

Step 6

To make sure our prices are up to date we have to schedule our script. A daily frequency is ok!

Schermafbeelding 2015-10-03 om 11.50.45

Where done!

Was it interesting? Share it, so someone else can read this too!Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

5 thoughts on “Google Adwords dynamic prices with Ad params”

  1. Hi, I tried implementing this script, but if my parameter includes a space like “€2,40 / Kilogram” it will trigger an error. I tried the one below, but this doesn’t fix it.

    var value2 = value2.replace(‘ ‘,’ ‘);

    Do you have any idea how to fix this?

  2. Hi Marthijn, thanks for the article. I am trying to use your script but I encounter 2 errors. The first one is that adwords doesn’t find the price I want to get from teh page source. Here is a sample of the source where the price is indicated:

    Prix généralement constaté :1 499,00 €1 239,00 €

    Where our_price_display is the one I want to have in the ads.
    The second error is ReferenceError: “els” is not defined. (line 55)

    I would be very grateful if you can help me with this.
    Many thanks in advance,
    Best regards,

    1. Sorry, the source snippet I’ve sent is not displayed, it turned to Prix généralement constaté :1 499,00 €1 239,00 €…
      Here it is again :
      Prix généralement constaté :1 499,00 €1 239,00 €

  3. Hey bud!

    Thanks for the epic script, however i can not make it work.
    I replaced all the undwanted data what i have left is the following

    Change to:

    {1}: {{{data.formatted_final_total}}} (!) Value is too long

    Any advice? thanks

Leave a Reply

Your email address will not be published. Required fields are marked *