Adwords Scripting to Enhance Your PPC Projects

Adwords Scripting to Enhance Your PPC Projects

(scroll to the bottom to copy a PPC script) Adwords Scripts are an incredibly useful, time efficient way to automate a huge number of Adwords activities which otherwise you would have to do manually.

This can range from analytic reporting or automated account alerts to making quick bulk changes to your accounts, which otherwise would have to be completed one at a time. Most importantly, Adwords scripts can be used to automate a range of PPC (Pay Per Click) orientated tasks making administrative processes far simpler, quicker, and less demanding of your time.

By helping users to work with the Google Adwords API directly and archiving all important data into a series of spreadsheets, for example, Adwords users can quickly benefit from a clearer understanding of which keywords are the most effective.

As with anything business related, streamlining and optimisation is king, so let’s take a look at some of the most powerful ways to use Adwords scripts to enhance your PPC projects.

Producing Reports

One of the most essential ways in which Adwords users measure the success of their PPC projects is to analyse archived data and to clearly identify which keywords are working for them and which are not. By doing this, Adwords users can focus on which keywords are yielding the best results. Unfortunately this is an unbelievably time consuming endeavour, costing you and your business countless hours as you sift through the data, cleaning it up, and attempting to glean the important information you require.

Anyone in the PPC business will tell you that this is terribly inefficient, but thankfully through Adwords scripts, it is possible to automate this process creating a series of advanced reports which can be quickly reviewed through a spreadsheet. By simply creating one reporting template and refreshing the data whenever you wish to generate a report – in combination with V-look ups and the occasional pivot table – what was once a time consuming process can now be performed with little or no hassle.

Copy & Duplicate Ad Groups

By using Adwords scripts effectively, it is possible to simply copy and duplicate any ad group, again freeing up your time from the monotonous task of creating each ad group manually. This is incredibly useful when developing individual ad groups by match type. In other words, if you have eleven ad groups to create, instead of spending the time entering the same information over and over eleven times, it’s a simple case of creating an ad group template and then hitting copy and paste.

Using Parameterized Ads

One of the annoying quirks of Adwords is that when altering any ad text, no matter how insignificant the changes, Google triggers a review process which results in the said ad text losing all of its performance data while taking more time than needed. The unfortunate thing is that as advertisers, we often need to tweak a phrase or keyword to see the best potential benefits. Sometimes it can take several attempts to get the advertising strategy and keyword use just right, so having to go through an entire review process every time the smallest change is made can be infuriating.

Thankfully, parameterizing ads is a great way to circumvent this issue through the as always useful implementation of Adwords scripting. These ads, also knowns as Ad Params, allow users to alter numerical values for any giving ad text without having to make a brand new ad while avoiding the review process. Very handy!

Let’s Try a Script

Enough talk, let’s try entering a script to begin with. At first this can seem a little daunting as the script is written in computer code. Not to worry though, if these things are beyond your area of expertise there are countless resources online full of pre-made scripts for you to use. Instead of learning how to code it is more important that you know how to copy and paste a script into the Adwords user interface.

Follow these steps:

#1: Log into your adwords page.
#2: Look at the navigation menu on the left.
#3: Look for ‘Bulk Operations’ and below that click ‘Scripts’.
#4: In the left hand corner you will see the option “+ Create script”. Click it.
#5: You’ll be provided with a box to enter your script.
#6: Find a script online that you wish to use to automate a desired function (we will provide one below).
#7: Highlight it, right click and select ‘copy’.
#8: Go back to the box in Adwords, right click on it and click ‘paste’.

There you go, you’ve entered your first Adwords script! To get you started, here are two scripts you can try below which are really useful.

Create an Automated Ad Performance Review

Paste the code below into Adwords to create Click Through Rate (CTR) statistics for your projects:

This script is protected using the Share Wall plugin, Social Share.

copy
Share This Snippet to copy it to your clipboard
// Comma-separated list of recipients. Comment out to not send any emails.
var RECIPIENT_EMAIL = ‘email@example.com’;
// URL of the default spreadsheet template
var SPREADSHEET_URL = “http://goo.gl/x0GDu0″;
/**
* This script computes an Ad performance report
* and outputs it to a Google spreadsheet
*/
function main() {
var spreadsheet = copySpreadsheet(SPREADSHEET_URL);
var headlineSheet = spreadsheet.getSheetByName(‘Headline’);
headlineSheet.getRange(1, 2, 1, 1).setValue(“Date”);
headlineSheet.getRange(1, 3, 1, 1).setValue(new Date());
var destinationUrlSheet = spreadsheet.getSheetByName(‘Destination Url’);
destinationUrlSheet.getRange(1, 2, 1, 1).setValue(“Date”);
destinationUrlSheet.getRange(1, 3, 1, 1).setValue(new Date());
spreadsheet.getRangeByName(“account_id_headline”).setValue(AdWordsApp.currentAccount().getCustomerId());
spreadsheet.getRangeByName(“account_id_destination_url”).setValue(AdWordsApp.currentAccount().getCustomerId());

outputSegmentation(headlineSheet, ‘Headline’, function(ad) {
return ad.getHeadline();
});
outputSegmentation(destinationUrlSheet, ‘Destination Url’, function(ad) {
return ad.getDestinationUrl();
});
Logger.log(‘Ad performance report available at\n’ + spreadsheet.getUrl());
if (RECIPIENT_EMAIL) {
MailApp.sendEmail(RECIPIENT_EMAIL,
‘Ad Performance Report is ready’,
spreadsheet.getUrl());
}
}
/**
* Retrieves the spreadsheet identified by the URL.
* @param {string} spreadsheetUrl The URL of the spreadsheet.
* @return {SpreadSheet} The spreadsheet.
*/
function copySpreadsheet(spreadsheetUrl) {
return SpreadsheetApp.openByUrl(spreadsheetUrl).copy(‘Ad Performance Report ‘ + new Date());
}
/**
* Generates statistical data for this segment.
* @param {Sheet} sheet Sheet to write to.
* @param {string} segmentName The Name of this segment for the header row.
* @param {function(AdWordsApp.Ad): string} segmentFunc Function that returns
* a string used to segment the results by.
*/
function outputSegmentation(sheet, segmentName, segmentFunc) {
// Output header row
var rows = [];
var header = [
segmentName,
'Num Ads',
'Impressions',
'Clicks',
'CTR (%)',
'Cost'
];
rows.push(header);
var segmentMap = {};
// Compute data
var adIterator = AdWordsApp.ads()
.forDateRange(‘LAST_WEEK’)
.withCondition(‘Impressions > 0′).get();
while (adIterator.hasNext()) {
var ad = adIterator.next();
var stats = ad.getStatsFor(‘LAST_WEEK’);
var segment = segmentFunc(ad);
if (!segmentMap[segment]) {
segmentMap[segment] = {
numAds: 0,
totalImpressions: 0,
totalClicks: 0,
totalCost: 0.0
};
}
var data = segmentMap[segment];
data.numAds++;
data.totalImpressions += stats.getImpressions();
data.totalClicks += stats.getClicks();
data.totalCost += stats.getCost();
}
// Write data to our rows.
for (var key in segmentMap) {
if (segmentMap.hasOwnProperty(key)) {
var ctr = 0;
if (segmentMap[key].numAds > 0) {
ctr = (segmentMap[key].totalClicks /
segmentMap[key].totalImpressions) * 100;
}
var row = [
key,
segmentMap[key].numAds,
segmentMap[key].totalImpressions,
segmentMap[key].totalClicks,
ctr.toFixed(2),
segmentMap[key].totalCost];
rows.push(row);
}
}
sheet.getRange(3, 2, rows.length, 6).setValues(rows);
}

Create a Keywords Performance Run-down
This script will provide data on specific keyword usage and its Quality Score.
// Comma-separated list of recipients. Comment out to not send any emails.
var RECIPIENT_EMAIL = ‘email@example.com’;
// URL of the default spreadsheet template
var SPREADSHEET_URL = “http://goo.gl/27L9k8″;
/**
* This script computes a keyword performance report
* and outputs it to a Google spreadsheet. The spreadsheet
* url is logged and emailed.
*/
function main() {
var spreadsheet = copySpreadsheet(SPREADSHEET_URL);
var sheet = spreadsheet.getSheetByName(‘Report’);
sheet.getRange(1, 2, 1, 1).setValue(“Date”);
sheet.getRange(1, 3, 1, 1).setValue(new Date());
spreadsheet.getRangeByName(“account_id”).setValue(AdWordsApp.currentAccount().getCustomerId());
outputQualityScoreData(sheet);
outputPositionData(sheet);
Logger.log(‘Keyword performance report available at\n’ + spreadsheet.getUrl());
if (RECIPIENT_EMAIL) {
MailApp.sendEmail(RECIPIENT_EMAIL,
‘Keyword Performance Report is ready’,
spreadsheet.getUrl());
}
}
/**
* Retrieves the spreadsheet identified by the URL.
* @param {string} spreadsheetUrl The URL of the spreadsheet.
* @return {SpreadSheet} The spreadsheet.
*/
function copySpreadsheet(spreadsheetUrl) {
return SpreadsheetApp.openByUrl(spreadsheetUrl).copy(‘Keyword Performance Report ‘ + new Date());
}
/**
* Outputs Quality score related data to the spreadsheet
* @param {Sheet} sheet The sheet to output to.
*/
function outputQualityScoreData(sheet) {
// Output header row
var header = [
'Quality Score',
'Num Keywords',
'Impressions',
'Clicks',
'CTR (%)',
'Cost'
];
sheet.getRange(3, 2, 1, 6).setValues([header]);
// Initialize
var qualityScoreMap = [];
for (i = 1; i <= 10; i++) {
qualityScoreMap[i] = {
numKeywords: 0,
totalImpressions: 0,
totalClicks: 0,
totalCost: 0.0
};
}
// Compute data
var keywordIterator = AdWordsApp.keywords()
.forDateRange('LAST_WEEK')
.withCondition('Impressions > 0′)
.get();
while (keywordIterator.hasNext()) {
var keyword = keywordIterator.next();
var stats = keyword.getStatsFor(‘LAST_WEEK’);
var data = qualityScoreMap[keyword.getQualityScore()];
if (data) {
data.numKeywords++;
data.totalImpressions += stats.getImpressions();
data.totalClicks += stats.getClicks();
data.totalCost += stats.getCost();
}
}
// Output data to spreadsheet
var rows = [];
for (var key in qualityScoreMap) {
var ctr = 0;
var cost = 0.0;
if (qualityScoreMap[key].numKeywords > 0) {
ctr = (qualityScoreMap[key].totalClicks /
qualityScoreMap[key].totalImpressions) * 100;
}
var row = [
key,
qualityScoreMap[key].numKeywords,
qualityScoreMap[key].totalImpressions,
qualityScoreMap[key].totalClicks,
ctr.toFixed(2),
qualityScoreMap[key].totalCost];
rows.push(row);
}
sheet.getRange(4, 2, rows.length, 6).setValues(rows);
}
/**
* Outputs average position related data to the spreadsheet.
* @param {Sheet} sheet The sheet to output to.
*/
function outputPositionData(sheet) {
// Output header row
headerRow = [];
var header = [
'Avg Position',
'Num Keywords',
'Impressions',
'Clicks',
'CTR (%)',
'Cost'
];
headerRow.push(header);
sheet.getRange(16, 2, 1, 6).setValues(headerRow);
// Initialize
var positionMap = [];
for (i = 1; i <= 12; i++) {
positionMap[i] = {
numKeywords: 0,
totalImpressions: 0,
totalClicks: 0,
totalCost: 0.0
};
}
// Compute data
var keywordIterator = AdWordsApp.keywords()
.forDateRange('LAST_WEEK')
.withCondition('Impressions > 0′)
.get();
while (keywordIterator.hasNext()) {
var keyword = keywordIterator.next();
var stats = keyword.getStatsFor(‘LAST_WEEK’);
if (stats.getAveragePosition() <= 11) {
var data = positionMap[Math.ceil(stats.getAveragePosition())];
} else {
// All positions greater than 11
var data = positionMap[12];
}
data.numKeywords++;
data.totalImpressions += stats.getImpressions();
data.totalClicks += stats.getClicks();
data.totalCost += stats.getCost();
}
// Output data to spreadsheet
var rows = [];
for (var key in positionMap) {
var ctr = 0;
var cost = 0.0;
if (positionMap[key].numKeywords > 0) {
ctr = (positionMap[key].totalClicks /
positionMap[key].totalImpressions) * 100;
}
var row = [
key <= 11 ? key - 1 + ' to ' + key : '>11′,
positionMap[key].numKeywords,
positionMap[key].totalImpressions,
positionMap[key].totalClicks,
ctr.toFixed(2),
positionMap[key].totalCost
];
rows.push(row);
}
sheet.getRange(17, 2, rows.length, 6).setValues(rows);
}