Code, Design, and Growth at SeatGeek

Jobs at SeatGeek

We are growing fast, and have lots of open positions!

Explore Career Opportunities at SeatGeek

Bid Automation on the Adwords API

A data-backed adwords campaign bidder

Adwords is great, but its built-in tools don’t always allow you to solve problems unique to your business. I was recently inspired by this post on Search Engine Land to build something similar off the Google Ads API.

There were a few problems on our account that couldn’t be solved by the Brainlabs solution.

  1. Because of the way our checkout process is structured, Adwords doesn’t know about our transactions. Until recently, this hadn’t been a problem; we have an approximation for transactions set up in Google Analytics, and the main KPIs for most of our campaigns are app downloads and email collection (things Adwords is aware of). But I wanted to use real-time transactional information to inform our bidding.
  2. I didn’t want to set up different scripts or bid modifier charts for each of our campaigns. People behave differently when buying Broadway tickets than they do when buying NBA tickets, and I wanted something that would calculate modifiers on the fly for each campaign.
  3. Finally, the major sports teams are spread out across three time zones. The “right time” to bid up a campaign for the Los Angeles Dodgers is different than for the New York Yankees, so I needed something that could handle those differences as well.

A few months back, we had our quarterly Hackathon and I decided to explore the Adwords API, which is pretty easy to sign up for.

There are several Google Ads API client libraries, like PHP, Ruby, Java, etc. I settled on the Python Libary because I hadn’t ever built anything in Python. This will become abundantly clear when you dive into my code.

You can find the script and instructions on how to set it up here. There are three major components of the script.

  1. Pulling transactions or whatever KPI you’re interested in from your database
    • We use Amazon Redshift, so my script uses the Psycopg2 package to connect to and query our database. If you’re running off MySQL, you can follow the instructions here in order to connect to your DB.
    • Make sure that any reporting you do is in the same time zone as your Adwords account. For example, our database records timestamps in UTC, but our Adwords account runs everything on EST.
  2. Working with the Adwords API
    • This file, adwords_api.py, contains every Adwords API-related call, from getting spend reports to modifying keyword bids.
    • This whole operation only runs on campaigns with a specific label. There are instructions here on how to find your label IDs, or how to modify the script so it runs on every campaign on your account.
  3. Modifying bids
    • This file, create_bids.py, actually calculates the bid modifier for each hour based on an ROI or CPA goal defined by you.

What will future versions do?

  • I’d like to write versions that work on the adgroup and keyword level. Currently, the script only calculates modifiers on the campaign level and then attaches them to every keyword in said campaign.
  • Right now, this script doesn’t take day of week into account. While conversion rate from SEM doesn’t change much day to day, I understand that day of week could be meaningful for some businesses. For SeatGeek’s purposes in particular, a future version that integrates time-to-next-event for each team would be a big improvement.

While this is certainly a work in progress, I hope this script can act as a jumping-off point for others to build something that works for their needs.

Comments