A script that detects anomalies at a local level

This script alerts advertisers when regional differences related to the coronavirus have an impact on your PPC campaigns.

Chat with SearchBot

Scripts are awesome for many reasons but the business conditions brought on by coronavirus have highlighted one of their most powerful benefits: they can be created cheaply and quickly. So much so that they can be deployed in quick response to unexpected events, even when there’s no expectation they will be useful for a long time. And when it comes to COVID scripts, we all hope those will be irrelevant sooner than later. But until then, they can at least help us get through stressful times with one less thing to worry about.

So far I’ve shared a script that annotates PPC performance with data about government responses to the virus. Martin Rottgerding shared his script that plots pre and post-covid performance of accounts for an entire MCC. Today, I’d like to share another script, one that alerts advertisers when there is an anomaly in performance in a specific location: the Geo Anomaly Detector.

Alerts are critical, especially now

Setting up helpful alerts should always be part of a PPC manager’s job. There’s simply too much data for humans to monitor manually. Normally alerts deal with fairly mundane PPC stuff like making sure monthly budgets aren’t exceeded, accounts don’t stop serving when a credit card expires, etc.

One alert many of us haven’t had to consider before, mostly because it wasn’t usually relevant, was a geo anomaly detector. Most advertisers already pay close attention to geographic targeting, geo bid adjustments, and performance at a regional level. But this is usually done under the assumption that each geographic region will exhibit reasonably consistent behavior over time. For example, if a car dealer tends to get more clicks in San Francisco than in other cities, that would normally be the case all the time.

But now with coronavirus, there are two unexpected new factors in play that impact geographic performance:

  1. How local governments restrict what businesses can do
  2. How consumer behavior changes in response to the virus

Whereas before one could safely assume that things wouldn’t change much in the various targeted geographies, now that’s changed and key performance indicators of search campaigns can have wild swings from one day to the next.

Finding out when KPIs behave in unexpected ways in a particular location was the premise for the Geo Anomaly Detector script I am sharing here today.

Geo anomaly detection example

I spoke about this idea conceptually during a recent PPC Town Hall. I had recently visited a Best Buy in California for a drive-up order and when I mentioned it to my dad who lives in Massachusetts, he told me his store was open like normal. 

That made me realize national advertisers with physical locations now had to account for an overwhelming number of different possible scenarios in all the locations where they are present. 

Whereas in California I had to order online and queue in the parking lot for my pickup, my dad was still allowed to walk into his local store in another state. But being older, he was not comfortable doing so. These two new variables could have a big impact on PPC performance and for advertisers it might be hard to stay on top of what conditions exist in all the locations they operate. 

But it wasn’t until Jordan Pierson from Supreme Golf emailed me with an idea for how to treat this scenario with a script, that the Geo Anomaly Detector came into existence. Jordan noticed that golf tee time bookings were impacted by differing local regulations as well as people’s behavior in response to COVID-19. Monitoring all their locations for sudden changes in performance was taking a lot of manual time.

And right now professionals simply don’t have that extra time, given some have to teach their kids at home or are picking up a bigger workload due to the virus.

What the script does

The Geo Anomaly Detector script uses several weeks of historical data to calculate the average performance for each combination of day of week and location where ads serve. It then compares this average (the ‘normal’) to yesterday’s performance. When the difference exceeds a user-defined threshold, it sends an email alert.

Image3 1
The script sends an email with details for any locations where yesterday’s performance is unusual compared to the typical performance for the same day of the week in that location.

The script also generates a Google Sheet with complete geo data so advertisers can browse it, even when there are no alerts.

Image2 1
The script generates a Google Sheet with columns of the typical performance and yesterday’s performance for each location where the ads are being shown.

Script settings

There are some basic settings first:

Image4 1
  • LAST_N_WEEKS tells the script how many weeks of historical performance to consider
  • EMAILS is a comma separated list of email addresses to notify when the script is finished running
  • MIN_CLICKS_PER_DAY sets a threshold for which locations to analyze so that those with too few daily clicks won’t be analyzed. This helps keep the number of alerts under control for big accounts

Next, there is a more complicated setting to indicate your thresholds for when to get alerts:

Image1 1

This is an object with an array of settings. The easiest way to use it is to just change the numbers and metric names rather than write the object from scratch.

  • INC_PCT refers to the percentage change. Any bigger percentage than this is eligible to trigger an alert
  • INC_ABS is the absolute change in the metric. Only if both the percentage and absolute change are exceeded will the script trigger an anomaly warning.

I recommend you run this script once per day, around 3 a.m. It’s not necessary to run it every hour as it only uses data through yesterday.

Install this script code in an individual Google Ads account:

Conclusion

I hope this script helps you more quickly find out when regional differences related to the coronavirus have an impact on your PPC campaigns. By finding out about these anomalies sooner, you’ll be able to more quickly take action and prevent wasted spend and capture more conversions.


Opinions expressed in this article are those of the guest author and not necessarily Search Engine Land. Staff authors are listed here.


About the author

Frederick Vallaeys
Contributor
Frederick (“Fred”) Vallaeys was one of the first 500 employees at Google where he spent 10 years building Google Ads and teaching advertisers how to get the most out of it as the first Google AdWords Evangelist. Today he is the Cofounder and CEO of Optmyzr, a PPC management SaaS company focused on making search, shopping, and display ads easier to manage with rules, scripts, reports, audits, and more. He is a frequent guest speaker at events where he inspires organizations to be more innovative and use AI and Automation Layering to become better marketers. His latest book, Unlevel the Playing Field, follows his best-seller, Digital Marketing in an AI World.

Get the must-read newsletter for search marketers.