**Resources**

The code and data for the marketing optimization found below can be found on my GitHub account by clicking here:

**Background**

The problem of optimally spending marketing dollars can be formulated in many ways. The goal of this post is to explain how to minimize advertising investment given a minimum communication goal for a given set of target populations. This post will leverage a constrained optimization framework to answer a simplified marketing problem, namely: how do can we minimize the marketing investment required and still reach our communication goals? The solution to the marketing problem will be obtained via Linear Programming and the Simplex Algorithm.

**Data**

The data above represent the media channels available for the marketing campaign: Television and Magazines. The reach of each one unit of advertising per media channel (e.g. one unit of TV reaches 5 million Boys, 1 million Women, and 3 million Men). The unit cost of each media channel (e.g. TV 600 and Magazine 500) and finally the marketing targets for the product being advertised in million (e.g. 24 million Boys).

I’ve saved these data to a Google Sheet which are then imported into R in the next section.

**Optimization Model**

The following questions represent a standard linear programming model specification, which is similar to the specification we plan on using in the empirical calculations in this post:

All the code for this analysis can be found on my Github account, click here. What follows is an explanation of this code which solves the marketing problem described above.

- Defining the Objective function and the left and right-hand side constraints

- Using the linprog package to solve the linear programming problem

**Marketing Recommendations**

The optimal solution is one that hits the target audience at the lowest costs. In this case the algorithm says this can be achieved by investing in 2.7 units of Television and 5.3 units of Magazine advertisement to hit the marketing goals of reaching at least 24 million Boys, 18 million Women, and 24 million Men.

The total cost of this marketing campaign is $4,266, not that this is the minimum costs associated with the cost minimizing allocation described above:

How many people were reached in this marketing campaign? Recall that the targets were a minimum requirement per target audience, so what is the real reach?

The first line shows that exactly 24 million Boys and 24 million Men were reached, which is the minimum level required by the communication goals of the campaign. However, 34 million Women were reached, with this marketing plan when the minimum communication goal was only 18 million Women reached. The reason is that the optimization has to simultaneously reach all the targets and do it at a minimum cost, having said that one can rest assured this is the cheapest way of reaching the communication goals.

**Ideas for Extending this Analysis**

Clearly many more women were reached than the communication goal intended. Adding additional marketing tactics besides Television and Magazines, especially ones that are especially efficient at targeting women will most likely hit all the targets at a cheaper price.

Time is certainly a factor when it comes to marketing effectiveness, here is a a previous post on measuring marketing effectiveness. Understanding not only how many people were reached but also how effective Television and Magazines are at different time horizons would likely improve this analysis.

This optimization does not take into account non-linear or synergistic effects of marketing, which again adds a bit more complexity but certainly be worth exploring. This would likely require a different type of optimization algorithm.

Expanding the marketing goals to include not only the reach but the frequency as one is likely to hit the same people multiple times via Television and Magazines. The number of times a person is exposed to a message can make it resonate and increase conversion (sales, revenue, web hits, etc.), but this analysis does not account for frequency of exposure the marketing message.

Despite all the limitations to this approach it still provides an mathematically precise way of creating a marketing budget that meets a set of specific goals. It is a good place to start introducing rigorous and proven algorithms to answer some very basic marketing questions.