# Model marketing attribution
URL: https://docs.datarobot.com/en/docs/api/dev-learning/accelerators/model-building-tuning/model-market.html

> Use DataRobot to streamline marketing attribution use cases.

# Model marketing attribution

[Access this AI accelerator on GitHub](https://github.com/datarobot-community/ai-accelerators/tree/main/use_cases_and_horizontal_approaches/marketing_mix_modeling)

Marketing attribution can be defined as the process of assigning credit to certain marketing activities (e.g., spending) as they contribute towards a desired goal (e.g., increases in revenue). Understanding how much these marketing activities contribute enables stakeholders to make better budget allocation decisions. However, in today’s world, marketing teams have many avenues to spend their marketing dollars, and it can be a daunting task to figure out which avenues are playing the largest role towards optimizing the key performance indicator (KPI) of interest. Model-based approaches can help sift through all this information in a rigorous and efficient way, leading to faster decision-making.

One of the most common ways to understand the attribution from each marketing channel of interest is to do live A/B testing (e.g., incrementality testing). That is, expose one group to marketing spend and another very similar group in nature to no marketing spend. Assuming all the sources of variability between the groups are reasonably satiated, you can measure a KPI (e.g., revenue) for both groups over a window of time and take the difference between them. This difference gives you information as to the lift that your marketing efforts had during the experimental window.

While the benefit of this method is deriving attribution via live-testing, some disadvantages include:

- A/B testing can be resource and time-intensive (e.g., you need many weeks to get a good picture of the differences, especially in different times of the year).
- Derived insights can only be gleaned from the experimental window (i.e., if you’re testing only for 10 weeks, you only have 10 weeks worth of data from the procedure).
- Many factors can influence business results such as competition, economy, local events, etc., so it can be difficult to truly isolate the incremental lift from marketing (i.e., experimental design is hard to do outside of a laboratory).

### Model-based approaches

In order to emulate the aforementioned A/B testing procedure (and assuming revenue is your KPI of interest), you need to be able to know the difference in revenue between when you expose your customer base to marketing and when you don't. While it’s possible to have days historically where you didn’t have any marketing spend, it’s more likely that you had some level of marketing spend activity each day. Hence, it’s impossible to go back in time to understand what revenue would have been without any marketing spend on each day in the past. This is where model-based approaches can help.

For the purposes of this accelerator, you can think of a “model” as “a set of steps a computer takes to find patterns or make decisions.” Different types of models exist, but the focus here will be on machine learning models, which are primarily used for predicting information you don’t know (such as revenue associated with no marketing spend). Specifically for marketing attribution, the steps may include:

1. Acquire historical revenue and spending data at the desired granularity (weekly, monthly, etc.).
2. Build a machine learning model that tries to learn how to predict historical revenue based on your historical spend (and other factors that can help explain revenue, like holidays, promotions, economic indicators, etc.).
3. Once your model has learned all it can from your historical data, you can begin using it to answer what-if questions like, “what would my revenue be if I increase spending in this marketing channel?” or “what would my revenue have been if I didn’t do any marketing spend whatsoever on this day?”
4. After you estimate what revenue would have been with no marketing spend each day in your historical data using the model, you can compare this value to the actual revenue on the given day to understand the total lift in dollars due to your marketing efforts.
5. Once the total lift is estimated, you can allocate this out to the individual marketing channels with the help of explanatory tools like Shapley values .

Having this machine learning model gives you the ability to help answer questions you normally wouldn’t be able to know about our historical data. It can also be used to understand future what-if scenarios too (e.g., "if I applied this allocation of spend across my marketing channels on this day in the future, what would my predicted revenue be?") and budget optimization (e.g., "out of the possible allocation strategies I have, which one will increase my revenue the most?").

### How DataRobot helps

DataRobot can help with marketing attribution use cases by:

1. Making building machine learning models incredibly easy.
2. Providing a Python API client that makes building custom workflows repeatable and scalable.
3. Having a suite of interpretability tools for each machine learning model (including SHAPley values).
4. Having connectors to databases such as Snowflake.
5. Having mechanisms to create straightforward applications to consume results (or that can write results back to the database for consumption of an internally-built dashboard)

These are just a few examples how DataRobot can streamline this process. Ultimately, a variety of ways exist for tackling marketing attribution and the process described below is just one way DataRobot has helped customers in the past. It is by no means the only way to do marketing attribution use cases.

---
