Getting Started With Google Adwords Scripts: Alert for Campaigns with No Conversions

This entry is part 1 of 2 in the series Google Adwords Scripts
10 Flares Twitter 8 Facebook 1 Google+ 1 LinkedIn 0 Reddit 0 StumbleUpon 0 10 Flares ×

javascript for adwords scriptsI’ve spent a lot of time lately tinkering with Adwords Scripts and aside from the fact that I want to keep too many of them active at a time, it’s been a fantastic way to dig into the inner workings of Adwords and have the platform proactively alert me or store data for me with very little daily effort on my part. So I’m here to share.

Here is a very simple script that can be used to closely monitor a campaign when conversions are of the utmost importance. This script doesn’t turn anything off or on for you, it just alerts you when campaigns statistics fall into the range you’re concerned about – in our case, we wanted a daily check on campaigns that spent money but provided no conversions. This isn’t always an issue, but when 3rd party web developers are testing landing pages or changing forms and you suddenly go from 20 conversions a day in a campaign to 0, knowing about it sooner is better.

Campaigns Spending Money w/0 Conversions
The Script

if you copy and paste, paste this into a plain text editor such as Notepad first


function main() {
// Get all campaigns with 0 conversions today.
var currentTime = new Date();
var today = (currentTime.getMonth() + 1) + "/" + currentTime.getDate() + "/" + currentTime.getFullYear();
var campaignsIterator = AdWordsApp.campaigns()
.withCondition("Status = ENABLED")
.withCondition("Conversions = 0")
.withCondition("Cost > 0")
.forDateRange("TODAY")
.get();
var TO = ['email_address1@yourdomain.com,email_address2@yourdomain.com'];
var SUBJECT = 'Campaigns Spending with 0 Conversions - ' + today;
while (campaignsIterator.hasNext()) {
var campaign = campaignsIterator.next();
var stats = campaign.getStatsFor("TODAY");
Logger.log( today + " - campaign " + campaign.getName() +
" cost " + stats.getCost() +
" and received " + stats.getClicks() + " clicks" +
" but had 0 conversions") ;
var EMAIL_BODY = ( today + " - campaign " + campaign.getName() +
" cost " + stats.getCost() +
" and received " + stats.getClicks() + " clicks" +
" but had 0 conversions") ;
}
MailApp.sendEmail(TO, SUBJECT, EMAIL_BODY);
}

 

That’s it! This is a very basic javascript instruction set that simply defines the criteria for the campaigns over a specified date. Let’s break that part down a little:


.withCondition("Status = ENABLED")
.withCondition("Conversions = 0")
.withCondition("Cost > 0")
.forDateRange("TODAY")

This is pretty straight-forward – any campaign foundĀ having the conditions we defined will cause their data to be recorded – if the campaign is Enabled (not paused or deleted), if there are no conversions, and if the campaign has spent money for the date range of, well, Today. (I defined the current date and setĀ a variable called TODAY in the first few lines).

The guts of the script gathers the data, builds it into a log report and then emails it to the email addresses that get entered into the email address variable – put your own email address(es) in there:


var TO = ['email_address1@yourdomain.com,email_address2@yourdomain.com'];

You can easily customize this script for different date ranges (yesterday, last 30 days, etc) and you can also easily change the defining threshold for cost or conversions. In this case, we want to be alerted when we have campaigns that spend money but have no conversion activity, and we set the schedule on the script to execute daily at 3PM. This gives the campaign enough time to actually generate conversions, but if there are no conversions by 3PM, it’s still early enough in the day for us to investigate. You can see a screen cap of where the scheduler is below:

sample script schedule

Other scripting resources for Adwords

Other Cool Ideas for Thing to do with Scripts

Feel free to let us know if you’re using scripts and how. As this technology is streamlined and expanded upon, the ability for DIY Deep-Dive PPC analysis will open up to anyone who can copy and paste!

Series NavigationGetting Started With Google Adwords Scripts: CTR vs Average Position >>
The following two tabs change content below.
Michelle has worked on the Internet (sometimes, literally) since before it had pictures, learned web development in HTML before it was iterated, worked in SEO when there were 12 search engines, watched Digg become the grandfather of social media, worked as a Google page rater, and predicted today's holistic online marketing environment back when MySpace was a thing. And she makes kick-ass fajitas.

Latest posts by Michelle Moore Scott (see all)

1 comment for “Getting Started With Google Adwords Scripts: Alert for Campaigns with No Conversions

Leave a Reply

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