top of page
Search

Part 4: Marketing spend optimisation

  • Writer: Nick Gavriil
    Nick Gavriil
  • Oct 26, 2024
  • 4 min read

The math behind optimal budget allocation



Introduction


LTV:CAC (lifetime value to customer acquisition cost ratio) is a very popular marketing efficiency metric and captures the unit economics of every business. Despite its popularity though, it can get confusing when it comes to understanding its variations, calculations and interpretations. So in this multi-part post I discuss from first principles the following topics:


  • Part 1: Misconceptions (covered here)

  • Part 2: Measurement framework (covered here)

  • Part 3: Optimal LTV:CAC ratio (covered here)

  • Part 4: Marketing spend optimisation


This is the final part of the series, where we will go over the practical aspects of optimising marketing budget allocation. This post will be highly technical. We will start with the mathematical formulation of the problem. We will then discuss response curves and finally we will go through 3 methodologies for optimising profit.


The Objective


A marketing team has been experimenting with 2 channels, channel 0 and channel 1. After testing various levels of spending for a few months, they have accumulated enough data and they would like to use them in order to inform their budget allocation across these two channels so that the total profit is maximised.

We can mathematically express this objective in the following way:






where q is the acquisitions generated from each channel, c is the total channel spend and LTV is the lifetime value for each channel. These equations express the total profit as the difference between the revenue (acquisitions x ltv) and the marketing spend, which are then summed across channels.


Response Curves


A response curve exhibits the relationship between the input metric of interest (e.g. GRPs, costs) and the independent variable (e.g. sales, acquisitions, revenue). There are 4 types of response curves:

  1. Linear

  2. Concave

  3. Convex

  4. S-shaped




Linear and convex curves are unrealistic, but they might appear in the data frequently when the range of marketing spend is limited and they capture the early or mid points of an s-shaped curve. So they could be used for budget allocation around the neighbourhood of what has been already tested, until higher levels of investment reveal the true nature of the channel.


For this post I generate data from the concave family and specifically linear-log curves as the pattern is found very frequently in marketing problems and it is very convenient when it comes to optimisation.





So the marketing team would have a dataset like the one below:



We can use this dataset to fit a regression model so that we can predict acquisitions for different levels of marketing spend for each channel, aka the response curve.



You might be wondering how this process is different to the estimation of acquisitions through a MMM. This dataset would be generated if the channels were thoroughly tested one at a time with channel costs varying randomly so that external conditions wouldn’t be confounders, which would create the need for us to control for them in our model. We are basically assuming that the dataset is generated through a multivariate test, with each variant being different levels of marketing spend repeated across each channel. This would be the purest form of marketing experimentation that allows this tutorial to be read in one go.


In part 2 of this series I talked about quasi-experimental methods that a marketing team has in their disposal to test channels that would generated data of equivalent or slightly lower quality to the one presented here.


Optimisation


The final step of this process is to allocate budget optimally across marketing channels. I will talk about 3 methods:

  1. Analytical solution

  2. Random search

  3. Nonlinear programming


Analytical Solution


Optimisation problems can sometimes be solved analytically but most often they get solved numerically. An analytical solution is an exact one that you can get by solving equations through pen and paper. A numerical solution is one you can get through trial and error with the support of a computer and it will be approximately correct. The problem I specified above has an analytical solution and you can find the math here. I solve the profit maximisation problem with the Lagrangian method and calculate the optimal values for the spend for each channel:





Finding analytical solutions would be the most efficient approach as there is an initial cost of doing the math but the solution can then be used at zero cost and no technical effort (only thing you need to know is how to use a calculator).


Random Search


This is a numerical way of solving the problem, where we are basically throwing darts against a wall and hope to get as close to the most profitable outcome. We go through a simulation of thousands iterations of combinations for the marketing spend across channels given that they sum up to the total budget. We then rank the iterations based on profit and pick the one that maximises it. Across the plethora of numerical solutions, this one would be the most inefficient because each iteration doesn’t utilise knowledge from previous rounds. It is though very convenient because it only requires basic arithmetic and programming skills to execute.



Nonlinear Programming


Computer scientist have developed sophisticated algorithms to solve optimisation problems. For this use-case I am using the python library cvxpy. It’s as simple as writing the following lines of code:


c_0   = cp.Variable(pos=True)
c_1 = cp.Variable(pos=True)

constraint = [c_0 + c_1 <= budget]

obj = cp.Maximize(b_0*cp.log(c_0)*ltv_0 - c_0 + b_1*cp.log(c_1)*ltv_1 - c_1)

problem = cp.Problem(obj, constraint)
problem.solve(verbose=False)

print({'c_0':c_0.value, 'c_1':c_1.value, 'max profit':problem.value})

This method would require around the same mathematical and programming knowledge as the random search but it’s magnitudes faster to execute, which would make it the preferred method for most problems. You can find the full code for this tutorial here.


Conclusion


We now conclude the series on LTV:CAC and marketing spend optimisation. A few takeaways:

  1. It’s important to get the fundamentals right. This includes things like choosing the right definitions for your metrics and using rigorous experimentation design methodologies to ensure that you have good quality marketing data.

  2. It’s highly unlikely that marketing measurement will be successfully done with a single data source (e.g. attribution). You will likely need multiple data sources that you can use to validate one another and reach unbiased conclusions about the performance of each channel. For example, in this post you could calculated LTV for each channel through attribution and the acquisitions survey and take an average.

  3. There are multiple methods that can be used to estimate the impact of marketing interventions but what’s more important is deep understanding of the marketing domain and marketing leaders with high integrity.

 
 
 

Comments


Follow me

  • LinkedIn
  • Instagram
  • Threads
bottom of page