Here’s a script to stop ads from showing next to offensive videos

At SMX West a few weeks ago, I was a panelist for the session, “How to Find, Hack, and Build Great Scripts.” I found one of the scripts presented by my co-panelists so interesting I decided it might be worth sharing with everyone here.

This script helps identify low-quality videos on YouTube that are monetized using your video ads. Specifically, it finds videos that have a high ratio of dislikes to likes, indicating it may be content that you’d rather not associate with your brand.

This script uses Google’s newest addition to AdWords Scripts — support for video campaigns — along with one of the advanced APIs for pulling YouTube statistics to solve the problem.

Low-quality video placements

As reported by The Guardian and several other news outlets, Google lost a lot of big brand name advertisers after a recent uproar about ads appearing alongside content promoting extremist and hateful viewpoints.

Unlike ads on search results pages, where we know the ad is appearing on Google.com next to a query that is closely related to what we’re selling, when it comes to ads placed through the Google Display Network (GDN), we don’t know exactly what the content of those pages is. Regardless of whether the ads are targeted to topics, audiences, contextual keywords or interests, it’s a combination of the bidding and matching algorithms that decides when to show an ad.

In-stream video ads appear in association with monetized videos. Because it’s hard to know whether a monetized video and its creator are a good fit for an advertiser’s brand, it’s critical to be proactive about checking where ads are appearing so that negative placements can be added.

Working with video campaigns in scripts

The last big announcement by the AdWords Scripts team is their support for video campaigns. For me and my team at Optmyzr (my company), this was exciting because we could finally start to do basic stuff like including video campaigns in scripts that help advertisers keep their spend within a monthly target budget.

But there are more advanced use cases, and Kris Belau from Firewood Marketing almost looked prescient by presenting a solution for limiting video ads that are shown on low-quality YouTube videos during our session on AdWords Scripts at SMX a week before the YouTube news hit.

His solution, which you can download here, pulls a placement report for video campaigns and then analyzes each YouTube video’s statistics using the YouTube advanced API that is part of AdWords Scripts. Any video that has too high a ratio of dislikes to likes gets saved on a Google Sheet where you can review it and then add it as a negative placement.

I have to include this personal anecdote because I thought it was a perfect real-life illustration of what we’re doing in this script. My one-year-old daughter loves corn, and when we try to introduce her to something new, like peas, she seems to have a knack for knowing when the ratio of peas to corn on her spoon is too high. When there are too many peas and not enough corn, it all ends up on the floor. With this script, you can spit out those videos that have the wrong ratio of good stuff to bad stuff.

Using the script through spreadsheets

When I tried to recreate a version of the same methodology, I kept hitting a roadblock. My placement reports never include the full URL of the video during which my TrueView video ad was shown. Without the full URL of the video, I have no way of knowing what the video was, and I can’t pull stats on likes and dislikes.

If you experience the same issue with Scripts and Belau’s code doesn’t work, you can try my version of it, which takes its inputs from a downloaded copy of the video placement report.

How to run this script

First, you need a copy of the report showing on which YouTube videos your video ads ran.

  1. Get this from your video campaign’s “Video Targeting” tab.
  2. Go to the “Placements” sub-tab.
  3. Select “Where ads were shown” and “YouTube” to see all automatic placements.
  4. Download this as a CSV and then open it using Google Sheets (be sure to convert it so it becomes a Google Sheet rather than a CSV).

Then it’s time to update the URL to your new spreadsheet in the scripts code, which you can copy and paste below. Replace the URL in the line “var spreadsheetUrl = “https://doc…” with your own spreadsheet URL.

To run this script, you need to authorize the advanced API for YouTube. This is an additional step that you may never have done if your scripts work has never ventured beyond some of the basics like integrating Gmail, Sheets and AdWords functionality. First, select the YouTube API from this list:

Next, go to the Google Developer’s Console by clicking on the link in the above authorization screen. There, find the YouTube Data API and make sure it’s enabled. You can also go to the Dev Console directly, but then you’ll need to make sure to select the correct project that is associated with the script. This can be a bit tricky, so I recommend just using the link Google gives you in your script.

After the script runs, your sheet will contain a few new columns with various YouTube engagement stats such as likes, dislikes, comments and so forth.

Belau’s methodology for finding videos to exclude is to look for those where at least a tenth of the votes are bad, i.e., “dislikes” / “likes” > 10%. However, because you have all the data for likes, dislikes and more in the sheet, you can experiment with your own methodology.

Once you’ve narrowed it down to a list of videos during which you no longer want your ads to show, simply copy and paste the list of URLs into the AdWords section for excluded video placements.

Taking this script to the next level

The beauty of AdWords Scripts is that you can build on the work of others. Take the basic methodology created by me or Kris Belau, and use our code as a starting point. For example, you could send the snippet text of a video and your calculated ratio into one of the other advanced APIs, the Prediction Engine. You can use that system to predict, based on the text of the snippet, what the ratio will be for videos that are too new to have a lot of votes. This would allow you to predict bad videos so that you could proactively filter them out rather than reactively deciding after they’ve accrued thousands of views and possibly already tarnished your brand.

To get the video’s snippet text, just use these lines of code:

var snippet = YouTube.Videos.list("Snippet", {

      id: videoId

    });

    

    Logger.log(JSON.stringify(snippet));

Another way to enhance the script is to make it fully automated. When you trust that you’ve found the right threshold for excluding videos, you can add a few lines of code to automatically add the negative placements to the right campaign.

Conclusion

Automation is a double-edged sword: it can lead to the engines showing ads in places that advertisers don’t like, but it can also be used by advertisers to undo the engine’s poor placement selection. As we deal with ever more automation in our industry, AdWords Scripts is becoming one of the most invaluable tools in our toolbox to help us quickly fix problems.

The post Here’s a script to stop ads from showing next to offensive videos appeared first on Search Engine Land.