1. SEJ
  2.  ⋅ 
  3. Digital Advertising

How to Use Automation to Ensure Brand Safety for Your YouTube Ads

With the right technology, you can place your YouTube ads where they drive results and eliminate placements that don’t. Here's how to build your own brand safety solution.


Proctor and Gamble (P&G) recently announced they slashed their digital advertising by $200 million in 2017.

While that’s a drop in the bucket of their $7.1 billion annual ad budget, it’s significant news because it’s counter to what we’re used to in digital marketing where budgets have continued to grow as consumers spend more time online.

P&G said that some digital spending had been largely wasteful.

According to the Wall Street Journal, Marc Pritchard, P&G’s chief brand officer has been concerned about digital advertising clutter, ad fraud, and brand safety issues on platforms like YouTube.

Where he sees a problem, I see an opportunity.

The beauty of online ads is that they can be targeted in unique ways not possible in traditional media and the results are highly measurable.

So with the right tools and technology, smart advertisers can place their ads where they drive results and eliminate placements that don’t.

I’ll share some code here that anyone can use to build their own brand safety solution for YouTube ads.

A Solution for YouTube Brand Safety

P&G has some specific concerns about ads that appear on YouTube. Last April, it was reported by The Guardian that ads sometimes showed next to inappropriate user contributed content.

But rather than shutting down YouTube ads completely and foregoing the opportunity to connect with millions of engaged consumers, I shared an AdWords Script for automating a system that eliminates ads next to potentially offensive videos. It’s based on an idea I got from Kris Belau from Firewood Marketing.

That script looks up how many thumbs up and thumbs down a video has received so you can automate adding a negative placement when a certain threshold of downvotes is reached.

According to Belau, this type of automation has helped identify a few hundred low quality videos while reducing the overall volume of campaigns by only about 5 percent.

Firewood also had success in using this code to find brand safe and high performance channels to target directly with the assumption that if a channel is hosting one good video then it’s likely to have other high quality videos as well, an assumption that so far has proven to be true.

Automation Changes the Human PPC Pro’s Role

Thanks to AdWords Scripts, custom automation is within reach of virtually any advertiser.

It would be cost prohibitive to ask your employees to review every place an ad is shown but it turns out that users have already done the work of reviewing placements by voting which videos they like or dislike.

When you know what technology like AdWords Scripts or the Ads API are capable of, you can build a solution that leverages this data.

To come up with solutions like this, PPC pros need to rethink the role they play in a world where automation is always improving.

It’s no longer about spending time fixing problems yourself, but rather about spending the time to identify the right technology to solve problems more reliably and more efficiently than any human could.

Doing AdWords Your Way

I used to work at Google and when I was there I believe we tried to do the right thing for advertisers and users. But often doing the right thing met fierce resistance from the ad industry.

For example, Google automatically switched advertisers’ campaigns to start showing on mobile devices when they launched Enhanced Campaigns.

It forced advertisers to get a mobile strategy in place, a good thing considering that the majority of searches now happen on mobile devices.

Regardless of Google’s intentions, advertisers who are used to managing accounts a certain way can find it disruptive when things change.

A recent example is Google’s switch to allowing twice the daily budget to be spent in one day, rather than the 20 percent overage that had been in place for over a decade.

Automation can help counteract these changes and buy advertisers some extra time to switch to the new way things are done.

I wrote a small AdWords Script that will pause a campaign long before it hits double its budget in a day. Advertisers can use it to restore the 20 percent overage rule, or even set any amount of overage between 0 percent and 100 percent.

This is the power of automation, we can have AdWords behave in the way that suits us best.

Combining Pieces of the Puzzle

I learned how to program when I was 12 so I know I have an advantage over someone who’s never written any code.

When I see a problem, I try to write a script that solves it.

But sometimes that engineering mindset has led me down the wrong path… one time I built a script to turn on different ads for the weekend and when I was done writing it, I realized I could have achieved the same outcome with a simple Automated Rule and some labels.

My solution worked, but I could have spent my time better if I had spent more time considering what options were at my disposal.

Luckily, figuring out what options are out there doesn’t require any programming skills so that’s something we can all do.

In some cases you’ll identify a solution that’s close to what you need, but not an exact match.

When it’s based on AdWords Scripts, it may require a small amount of tweaking the code and copy-and-pasting may no longer be enough.

But in other cases, several partial solutions could be combined to get you to where you want to be.

That’s when it can be helpful to apply one principle of an engineer’s mindset: figure out how to string together a set of tools to get you to your desired endpoint.

For example, the script I referenced before to identify bad YouTube placements requires several manual steps.

At the time I wrote it, the AdWords system didn’t give me the full URL of placements.

Rather than saying which video my ad showed next to, it simply told me my ad was shown on YouTube. So I had to manually place the full YouTube URL with the video ID in a Google Sheet before the rest of the automation could work.

Then recently, I wrote a script that takes any AdWords query and puts the resulting report data in a Google sheet. I wrote it to help users of my company’s tool do some advanced rules-based optimizations.

But with the P&G story fresh on my mind, it dawned on me that this script could also automate the first part of the YouTube solution I wrote last year.

By running these two scripts together, most of the brand safety management on YouTube can be automated. The first script gets all the placements where ads have appeared and the second script uses this data to find low-quality placements.

From there it’s a small step to add the resulting bad placements to the campaigns, either through Editor or automatically with a few more lines of code.


Online is still the most flexible and measurable advertising channel we have and it is where our prospective customers are spending a lot of time.

When we feel some of the results are subpar, we can wait for the search engine to address our complaints or we can be proactive and leverage technology to be a leader and build a solution ourselves.

This is a big opportunity.

When competitors sit on the sideline waiting for the fix, it’s a chance for savvy advertisers to have the playing field all to themselves and still drive great results with custom automation.

Here is the code for the two scripts mentioned in this post.

YouTube Script

Reporting Script

More YouTube Advertising Resources:

Image Credits

Featured Image: Worawee Meepian /

VIP CONTRIBUTOR Frederick Vallaeys Optmyzr

Frederick Vallaeys is a Co-Founder of which offers a Historical Quality Score Tracker, One-Click AdWords Optimizations, a custom report ...

How to Use Automation to Ensure Brand Safety for Your YouTube Ads

Subscribe To Our Newsletter.

Conquer your day with daily search marketing news.