Of course my common answer was to use scripts, and there wasn’t a single question for which that was the right answer. In fact, I don’t even recall a question where scripts was a possible answer. By comparison, you are expected to know information about API usage, a very complicated process best suited for professional programmers, not just advanced Adwords practitioners.
Personally, I think it’s a huge miss on Google’s part. Adwords scripts can accomplish fairly simple, elegant solutions to routine problems.
Let’s take for example the concept of ad scheduling. It’s an important concept for anything that’s time sensitive. The common use case is to completely stop showing a campaign during times that are not appropriate. This works great if there’s only on or off that matter.
But imagine the case of a restaurant that wants to promote happy hour and lunch specials. Using just ad schedules, it would need two separate campaigns with two separate schedules. If they always wanted to run a “base” conversion campaign as well they’d need three. Maintenance is now three times as complicated, and data is stretched extremely thin and hard to aggregate. It’s also easy to lose control of budgets unless also employing a shared one between the three. It’s kludgy to say the least.
First we need to label our ads, which is easiest to do within the interface. In this example we could call them “HH” or “Lunch”. Our ad group iterator can then use a condition to select based upon these labels and pause or enable the campaign. To keep the logic simple we can employ separate scripts for each “switch” and not have to have any complicated if then statements or time lookups.
Stating it in my typical framework of what we want to accomplish sounds like this: “Enable ads labeled ‘HH’ and pause those without that label when we run this script everyday around 4 o clock.” The framework telling me that I need to selected based upon Label Names and iterate through them to pause or enable as needed. It’s also telling me to schedule the script.
In code, it looks like this:
var CAMPAIGN_NAME = ‘Chotchkies’;
function main() {
// Set Lables as appropriate
pauseAdsWithLabel(“Lunch”);
enableAdsWithLabel(“HH”);
}
function enableAdsWithLabel(eLabel) {
var adsIterator = AdWordsApp.ads()
// condition could also be STARTS_WITH instead of =
.withCondition(“LabelNames = ‘” + eLabel + “‘”)
.get();
while (adsIterator.hasNext()) {
var ad = adsIterator.next();
ad.enable();
}
}
function pauseAdsWithLabel(pLabel) {
var adsIterator = AdWordsApp.ads()
.withCondition(“LabelNames = ‘” + pLabel + “‘”)
.get();
while (adsIterator.hasNext()) {
var ad = adsIterator.next();
ad.pause();
}
}
A few notes on the code.
First, I don’t actually use the campaign name anywhere in the code, but needed to slip in an Office Space reference somehow. As a result the script traverses the entire account. It’s very possible to actually use a campaign name condition or even an ad group condition to limit the scope.
Second, There’s no need to do anything schedule the script to run when the switch needs to happen on a daily basis. I’d recommend scheduling a copy of the script to run when the events need to reverse, since it’s much easier than trying to add the time logic needed for an hourly run.
Third, there are other ways to accomplish this same task. It’s possible to use a label class and have it return an ads iterator. It might be more “elegant” that way, but much harder to explain. So ignore this part unless you are a real programmer and want to show off.
Finally – Scheduling scripts. This Google makes super easy. In bulk operations, right next to where the script was created, there’s a plainly labeled link to “create schedule”.
Steve Hammer
Latest posts by Steve Hammer (see all)
- Overcoming AdWords Conversion Data Discrepancies - February 12, 2015
- Near Exact Match Monitoring AdWords Script - August 15, 2014
- Why the Advanced AdWords Certification Exam Made Me Write An AdWords Happy Hour Script - August 4, 2014