How to use machine learning to optimize your marketing spend

by Alex, Co-Founder

With most businesses we work with, advertising and marketing tends to be their second or third largest expenditures. Determining the effectiveness of this expenditure in driving ROI can be challenging due to the all of the factors influencing sales.

To make this more complex, attribution systems are becoming less useful in the marketing world due to the loss of cookies. With less, aggregated data, tools like machine learning can help provide a strong lever to understand the effectiveness of our media in a privacy safe way.

How to Use ML for Marketing:

  1. Collect Data: Think of data as the "examples" you show the computer. This includes:
    • How much money was spent on ads by channel
    • How many products were sold
    • Other important things, like holidays or big sales events
    • Geopolitical activity
    • Interest rates
    • Gas prices
    • Weather data
    • Organic impressions
  2. Prepare the Data: Before ML can work its magic, the data needs to be in order. We need to be able to explain missing data, align the dates correctly, and segment the data in the right ways.
    1. A few things to consider: Do you want to split the data by media channel? By campaign? By brand media vs DR media? By geo? By product line and media channel? By store? What granularity? Daily? Weekly?
    2. How you represent the data is arguably more important than the tools you choose to model it.
    3. History is important. One tip is to aim to have 10 - 20 days of data for each media channel and data point you use in your model. E.g. 6 media channels can be minimum 120 days of history. The more history you have, the more likely you are to capture long-term seasonal impact.
  3. Choose the Right Model: This is where things can go wrong. Some models are excellent at leading you astray. There are many open source models you can explore:
    1. Robyn by Meta (Open Source) - R-based
      1. Implements hyperparameter optimization, which involves running the model thousands of times with different parameters to find the optimal combination for the most accurate results. Robyn also uses the Prophet library for time series forecasting, and Meta's Nevergrad Python library for optimization using modern machine learning techniques like Bayesian optimization and genetic algorithms
    2. Lightweight-MMM by Google (Open Source) - Python-based
      1. Utilizes Bayesian algorithms and Numpyro as a backend for conducting Bayesian Marketing Mix Modeling (MMM), which provides a flexible framework for dealing with uncertainty and variability in the data through probability distributions. This approach tends to generate more accurate predictions and insights compared to traditional linear models
    3. Custom Machine learning-based models such as Random Forests, MLPs, etc have also been used to model nonlinear interactions of media channels.
    4. Ensure the type of model you use accounts for “ad stock” to help you understand the impact of brand media.
      1. Ad stock is the idea that the effects of advertising don't immediately dissipate after exposure, ad stock takes into account the cumulative effect of ads, decaying over time based on a specific rate known as the decay factor.
    5. The effectiveness of a particular model can vary and it might be beneficial to consult with your data scientists or ML experts before using off-the-shelf libraries.
  4. Train the model: Using your prepared data, feed it into your model. This could take hours depending on the amount of data, algorithms, and computational resources. That said, this can be where a lot of time is spent if you plan on experimenting with different combinations of data.
  5. Test the model: Don’t skip this step. This is where we learn how accurate your model is on predicting over data you’ve never seen before.
    1. Use proper cross-validation techniques and split your data accordingly.
  6. Calibrate your models using lift studies (recommended): Google’s Conversion Lift and Meta’s Lift Studies give us the data we need to calibrate our MMM models and make sure that we are crediting platforms more accurately.
  7. Use your model: All models are wrong, but some are useful. Trusting your model and giving it a go can pay off. Using a combination of machine learning methods and the right data can show you where your ROI is truly coming from and where waste can be cut.
  8. Deploy, retrain, and monitor: Results from the first month are going to be addicting, make sure your models stay up to date through retraining, monitoring, and consistent deployment so that you have the most up-to-date results.

In many industries, modeling your media is the standard for marketing; in others, many businesses are just learning what ML is capable of. It can be incredibly rewarding to have a robust marketing model—every percent of accuracy matters, drives ROI, and ensures that every dollar invested is well-spent.

We’re happy to set up time to chat data, marketing, modeling, data privacy, cookie loss, and more. Feel free to contact me here.

More articles

What Wall Street can teach us about AI

Discover the evolution of algorithmic trading, from its discreet beginnings to its dominance in the financial landscape, and learn how businesses can harness its power to navigate the complexities of the global market and achieve sustainable growth.

Read more

Tell us about your project

Our offices

  • Detroit
    2211 S Telegraph Rd Suite 8063
    Bloomfield Hills MI, 48302