Dynamic prices and discounts in Adwords ads
People ask us very often to update product information in ad texts from a Product Feed. Sometimes adjusting the prices is already enough. In this case it’s not necessary to update the whole ad text. You can use the “AdParams” function of the Adwords API. With this function you can give in a variable value, almost the same as the dynamic keyword function of Adwords.
How do AdParams work?
AdParams are almost the same as the common “Dynamic Keyword Insertion”. Only now we do not enter a search word, but a value. This can be a price, discount percentage, date, time or something else. You can draft such an ad like this: 1. Create an advertisement with the placeholder before the parameter. 2. Give every search word in the ad group a value. 3. If this search word activates an advertisement, the placeholder in your text will be changed for the value you gave to the search word.
Writing an ad with a parameter
We start by drafting an example ad. The syntax for the parameter is {param1:default}. We now enter an example ad text:
The advertisement text with parameter.
Because there are no parameters specified yet, we will see the ad with the standard (default) value of 20%.
The ad like it's shown in the search results.
Specifying a parameter per search word
Now we will want to enter a value for the parameter of the search word we used. This goes via the Adwords API. We used the following PHP Script:
<?php
require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
// AdWords API Credentials
$username = "test@example.com";
$password = "vulhierjewachtwoordin";
$customerId = "123-456-7890";
$developerToken = "vulhierjedevelopertokenin";
// Create an AdWords API user
$user = new AdWordsUser(null, $username, $password, $developerToken);
$user->SetClientId($customerId);
// Get a reference to the AdParam service
$adParamService = $user->GetService('AdParamService', 'v201109');
// Create an AdParam for a specific keyword
$adGroupId = "KEYWORD_ADGROUP_ID";
$criterionId = "KEYWORD_ID";
$insertionText = "30%";
$paramIndex = "1";
$adParam = new AdParam($adGroupId, $criterionId, $insertionText, $paramIndex);
// Upload the new AdParam to AdWords
$operation = new AdParamOperation();
$operation->operand = $adParam;
$operation->operator = "SET";
$operations = array($operation);
$adParams = $adParamService->mutate($operations);
?>
If you adjust the right variables in this script, Google will show in ca. 5 minutes the new discount value of 30%.
How does this code work?
The first part of this code is the usual code to get access to the Adwords API. For this you will need your developer token, Google mail and password, and the customer ID of the account you want to have access to. Below is made a reference to the API service.
$adParamService = $user->GetService('AdParamService', 'v201109');
Now we get to the most important part of the script. In this part the advertisement Parameter will be created.
$adGroupId = "KEYWORD_ADGROUP_ID";
$criterionId = "KEYWORD_ID";
$insertionText = "30%";
$paramIndex = "1";
$adParam = new AdParam($adGroupId, $criterionId, $insertionText, $paramIndex);
For this part of the code you will need the API Id’s of the ad group and the search word for which you want to specify the parameter. You can get this by getting a report in the Adwords user interface. Then you need to insert a parameter value at the variable: “$insertion Text”. When you are finished you need to put the “$paramIndex” on 1 or 2. You can view their definitions on the next page
The $insertionText variable
This is the most important variable of the PHP code. With this variable you can set the replacing placeholder in the ad text. Enter, for example, 30%. You can use this variable for many more things than just prices and discount percentages: - You can use dots and commas: 2.999,50 - You can add valuta currency symbols before and after the number: €30 and 30€ - You can use plus and minus symbols: +20 and -10 - You can separate two numbers by using a slash forward: 50/50
You can not use more than 25 numbers and letters in a parameter. Also, you still have to keep in mind the standard conditions of the amount of letters per line.
The $paramIndex variable
With the help of this variable you can change between two possible parameters “param1” and “param2”. You can add two parameters per ad. So, you can at the same time mention a price and discount. For this you need to put the $paramIndex variable on 1 or 2.
Deleting an Ad Parameter
You can easily delete a value you added earlier by using the same code. For this, change the “service operation” from “ADD” to “REMOVE”.
// Upload the new AdParam to AdWords
$operation = new AdParamOperation();
$operation->operand = $adParam;
$operation->operator = "REMOVE";
$operations = array($operation);
$adParams = $adParamService->mutate($operations);
?>
The advantages of using AdParams instead of adjusting your whole advertisments
Making a few small adjustments to advertisement texts has some disadvantages. You will always make a new ad. Even when you just change one letter. By doing this, you will lose all previous conversion data and your ad needs to pass the complete approval process again. By using the method above, you can pass these disadvantages and your ad will be adjusted very quickly. It also costs less API units than adjusting your whole ad (40 vs. 0.1). Finally, by using the AdParams method you have the possibility to integrate dynamic prices in ads with a product feed. So, there is a lot of potential for automation and you can maintain big campaigns.
Download 2 Free e-books on Google AdWords
Learn how to use AdWords to gain more traffic to your web site or web shop and how to optimize your bids. Both e-books are published by Google!