Google AdWords scripts

Let’s wander from the web analytics subject a little and turn our attention to automation of creating Google AdWords campaigns and AdWords campaign management.

Few people know that Google AdWords provides the ability to manage ad campaigns using javascript directly in the interface of the system through Adwords API.

By the way, getting access to Google AdWords API, i.e getting API token, is not that easy.

To gain access to scripts, go to Google Adwords account and choose “Bulk operations” in the right menu, and than “Scripts”:

Got tired of low conversions?

Our certificated experts know how to optimise your Google AdWords campaigns so that conversions increase by 35%

By clicking this button you agree to our terms & conditions

The next step is to create new script:

To work with the scripts you need to login:

Now when you are authorized you are able to do anything with AdWords PPC management: to manage ad campaigns, ad groups, ads and keywords in AdWords by means of javascript.

By default, there are some complete scripts that solve the following problems on AdWords optimization:

Campaigns 

Get each campaign’s cost and clicks last month

Pause low-converting campaigns

Change campaign’s budget

Ad groups

Set default bids of all ad groups in a campaign

Enable ad groups for a brand

Pause ad groups that degrade over time

Keywords

Log 20 keywords that had the most impressions yesterday

Pause keywords with bad average position in a campaign

Increase bids of well-performing keywords by 5%

Create a new keyword

Export daily report into Google spreadsheet

Change destination URLs

Ads

Enable ads for a promotion

Create a new text ad

Export disapproved ads into Google spreadsheet

Also, see below an interesting case of using Adwords script:

Controlling expenses

Let’s suppose we have the task of monitoring expenditures on a certain campaign. This task could be ordinary solved using standard AdWords tools, but using AdWords scripts guarantees us an elegant solution.

So, to complete the script we need:

  1. Name of a campaign
  2. Limit size
  3. Start date of tracking
  4. E-mail for notifications

All these data need to be entered into the electronic worksheet (save it onto the Google Disk and save the link from a browser of your document as you will need it while making the following steps).

The spreadsheet may be colored to one’s liking, but we won’t advice to change the location of the cells. Fill in the lines that are highlighted in bold.

The algorithm works as follows:

  1. Once an hour (that is the maximum possible frequency) the script takes the name of the campaign from the table, limit size, start date tracking;
  2. Calculates expenses;
  3. Checks whether the campaign is active. If the answer is yes, the script makes control marks in the table. If the campaign is not active, the script doesn’t make any action and just stops.
  4. Requests a daily account budget (it is explained below why it is done);
  5. Makes calculations, compares expenses on the campaign starting from a certain date to the present moment, with the deactivation threshold. If the deactivation threshold achieved, it goes to the point #6;
  6. Disables the campaign;
  7. Sends an email to the specified email address;
  8. Makes a corresponding note in a Google table about campaign being disabled and the time of deactivation.

See below the complete script:

function main() {

var ss = SpreadsheetApp.openByUrl(
“https://docs.google.com/spreadsheet/ccc?key=0Ahq3mrXBUIYHdDBtZS1FUFBuamZQU2FWSTB4MzZDT1E#gid=0”);//link to your table
var balance = ss.getRange(“C3”).getValue();  //limit size
var data_start =  ss.getRange(“C4”).getValue(); //Start date of tracking
data_start = Utilities.formatDate(data_start, “PST”, “yyyyMMdd”);
var data_today = new Date();//Today’s date
data_today = Utilities.formatDate(data_today, “PST”, “yyyyMMdd”);
var company_name = ss.getRange(“C2”).getValue(); //Name of campaign that is tracked
var email = ss.getRange(“C5”).getValue();  //E-mail for notifications
var cost = 0;// Initial cost
var status = ss.getRange(“E7”).getValue(); //Status of campaign (if disabled  by script)
var campaignsIterator = AdWordsApp.campaigns()
.withCondition(“Name = ‘” + company_name + “‘”)
. get();
while (campaignsIterator.hasNext()) {
var campaign = campaignsIterator.next();
var stats = campaign.getStatsFor(data_start, data_today);
cost += stats.getCost();
}//Determining the cost of expenses for the specified period of time
if( campaign.isEnabled()){
ss.getRange(“E7”).setValue(“0”);
ss.getRange(“D7”).setValue(“”);
//Determining the status of the campaign enabled/disabled. If enabled updates service information.
var budget = campaign.getBudget()
Logger.log(“Spent during the period: ” + cost);//Debug information is displayed in the log
Logger.log(“Daily budget: ” + budget);
Logger.log(“Expenditure restraint: ” + balance);
var budget=campaign.getBudget()//Determining daily budget
if (cost >= balance-(budget/12)) {//Checking overspending
campaign.pause();//Put the campaign on pause and write an email
var subject = “Campaign” + company_name + ” exhausted its budget limit”;
var body = “Spent: ” + cost +  ” Specified spending limit:” + balance + ” campaign ” + company_name + ”  will be disabled” ;
MailApp.sendEmail(email, subject, body);
Logger.log(“email sent: ” + email);//Debug information is displayed in the log
ss.getRange(“E7”).setValue(“1”);//Control mark in Google table
ss.getRange(“D7”).setValue(new Date());//Record to the time table and date of stopping campaign
}
}
}

You may also want to check the developer’s guide.

via

 

 

Leave a Reply

avatar
  Subscribe  
Notify of

Recent posts

Call tracking with dynamic number insertion (DNI): how to track the ad source of inbound calls

March 12, 2021

When it comes to effective distribution of marketing budgets, eCommerce businesses that accept orders not only through the digital carts on the website but also through inbound calls, all face the same problem: the inability to see a unified picture of marketing channels that brought customers to their decision to purchase. Here call tracking tools Continue reading >

How to combat cart abandonment with UX: detecting common checkout mistakes of eCommerce brands

February 23, 2021

Online checkout stats shows that more than 80% of online customers abandon their shopping carts. Out of them, about 87% are going to finish their order later. We are not sure if businesses are ready to sacrifice and lose time waiting for those 87% to return and complete the checkout, that’s why in this article Continue reading >

Making the most of email marketing in the beauty industry | Case Study

January 29, 2021

How to engage your mailing subscribers to visit your website? What’s the optimal mailing frequency? How to increase your conversion rates with email marketing? These questions are frequently asked by marketers. The situation gets even more challenging when it comes to the subscribers of a well-known beauty brand. In this material, we share the email Continue reading >

How to market furniture: email, content and remarketing as parts of IKEA marketing strategy

January 28, 2021

Furniture marketing is peculiar for certain reasons. First is that for customers buying furniture this is often emotional and exciting. Second is that this process, when online can take time – there is no way to literally “try on” or test an item. And third is that quality furniture costs money, almost like a small Continue reading >

Let's get the ball rolling

Please fill in this short form and we will be in touch with you soon

For any questions [email protected]

UK | USA | EST

+44 (0) 20 313 766 81
+44 7852 537715

Lincoln
The Terrace AT5,
Grantham Street,
LN2 1BD

+1 347 809 34 86

Las Vegas
6920 S. CIMARRON RD.,
Suite 100,
NV 89113

Tallinn
Roosikrantsi 2-K230,
Kesklinna linnaosa,
Harju maakond,
Tallinn 10119

CEE Ecommerce Report 2019

Based on the analytics data of 292 websites

enter correct name, please
enter correct e-mail, please
PPC

Google AdWords scripts

0
start now

Start now