The main objective of an ad server is to offer choice and delivery of advertisements. However, when the user went through all the ins and outs of targeting and can receive multiple advertisements from different advertising campaigns, the question arises: which ad to choose? Our product has a standard solution – with each request, ads are ranked based on bids, while also adding the element of probability. In other words, the probability of an ad being shown depends on the bid. On one occasion, a customer offered to perform the customization of the ad server where the ads are chosen from a list prepared in advance, with major changes in the algorithm of choosing the ad.

Despite the simplicity of implementation, the standard algorithm for random ad selection has one drawback – it does not control the display process. That is, we load the available ad in an arbitrary manner, not worrying about the interests of partners and advertisers. However, in order to improve the competitiveness of the entire system, it is necessary to come up with some advantage that separates us from other systems. The point of the new algorithm is to find the balance of benefits for advertisers and partners. So how do we do that? First, you need to define the objectives of both parties. For the partner, the goal is obviously to get as much money from an advertising platform as possible. However for the advertiser, on the contrary, the goal is to spend less money, but spend it most effectively.

As universal metrics, we selected CPA and CTR for display server to rank ads. CPA is the cost of the action for the advertiser, the user’s actions, which will bring profit to the advertiser. Such actions can be assumed to be a purchase in an online store, order of services, etc. The main difference in the updated system is that when you create a campaign, the advertiser cannot set the rate for an ad; the advertiser only indicates the CPA and achieving it is one of the main tasks of server hits.

It is necessary to elaborate on the data architecture. For each advertising partner location, or the source, we create their own individual list of ads. The system administrator manages the process. He, at his discretion, adds to the source of campaign ads that need to be rotated in this source. In addition, ads for each source have their own bid and rating. Bid is the amount of money that the advertiser will pay for showing 1,000 ads/CPA/CPC. Nothing changes here, except for the fact that the bid for each source will be different, calculated by the system. Rating is a measure of how often your ad appears in the source. The higher the rating, the higher the probability of an impression. The calculation of each parameter corresponds to a module. Let’s look in more detail at each module.

The objective of the AdRater is to recount ad rank for a particular source. Rating of each ad will be increased or decreased based on the algorithm using the values ??of CTR and CPA. The main task of the algorithm is to increase the rating of ads on the list that have a higher CTR and lower CPA. In other words, at each iteration of the algorithm, the ad rating refreshes depending on the CTR and CPA. The essence of the work is as follows: we consider a specific ad group (the same one that was created as a result of the selection by the administrator) for the appropriate source. All calculations are carried out for this group, which is closed and is not associated with other groups of ads for other sources. Since the goal is a higher CTR and lower CPA, then ads with higher CTR and lower CPA should be shown more often in this group. This raises the problem of how to determine the ranking in these specified limits? The most obvious way is to calculate the structure of the index. Take, for example, the following ad group:

ID | CTR | Target CPA | Real CPA |

1 | 0.1 | 0.5$ | 1$ |

2 | 0.25 | 1.5$ | 2.5$ |

3 | 0.2 | 1$ | 0.5$ |

In a series of three ads, for example, the first has a CTR 0.1, the second has a CTR 0.25 and the third has a CTR 0.2. All of these values ??for the ad are just for that source, and for no other. As a total, we’ll take the sum of CTR for these ads to be 0.55. The first ad has a weight of 0.1 / 0.55 = 0.18; the second ad has a weight of 0.25 / 0.55 = 0.46, and the third ad has a weight of 0.2 / 0.55 = 0.36. Therefore, all things being equal, the probability of the first ad being displayed is 18%, the second ad – 46%, and the third ad – 36%. This is the calculation of the CTR rating.

CTR rating is beneficial for the partner, but we must also take into account the interests of advertisers. To do this, we need to calculate, for each ad, the reverse relative CPA rating (reverse – as the smaller CPA, the better). Reverse rating is calculated as 1/(RealCPA/TargetCPA).

For the above example:

For the first ad, the reverse weight proportion of 1/($ 1 / $ 0.5) = 0.5, for the second ad 1/($ 2.5 / $ 1.5) = 0.6, for the third ad 1/($ 0.5 / $ 1) = 2.

We normalize the values ??(with new parameters) and get the rating for the first ad of 0.5/3.1 = 0.16, the second ad of 0.6/3.1 = 0.19, the third ad 2/3.1 = 0.65.

The goal of the algorithm is to find the balance of benefits for advertiser and partners. In order to achieve this, the proposed value of each rating is multiplied and normalized for easy perception. Multiplication will avoid high ranking distortions (when an ad is very beneficial for the partner, but is unprofitable for the advertiser), and give a high rating to the ads that are most beneficial for both parties. Normalization will facilitate the perception of ratings. For the described example: the rating of the first ad 0.18 x 0.16 = 0.029, ranking of the second ad 0.46 x 0.19 = 0.087, and ranking of the third ad 0.36 x 0.65 = 0.234. After normalization (also calculated by weight and interest), we get the ranking of the first ad = 8%, ranking of second ad = 25%, ranking of the third ad 67%. The ads will be displayed in the source with these probabilities.

If we remove the dry numbers and try to simplify: the higher rating will be for the ad which has the highest CTR and CPA.

The objective of the Bid Optimizer is to recalculate the ad bids for each source. Bids can be increased or decreased using RealCPA values ??and TargetCPA. The essence of the algorithm is as follows. For each source and ad, we calculate the percentage difference between RealCPA and TargetCPA. If the value of RealCPA is higher than that of TargetCPA, we downgrade the bid by the percentage difference. A similar situation occurs if the RealCPA is less than TargetCPA – we increase the bid and give your partner a chance to make more money.

The result of these two modules is the following – for each ad in the source, there will be just such a bid, which will help make the maximum amount of money for the partner, but without departing from the advertiser restrictions. At the same time, the ad will be rated, allowing it to show more often, depending on the effectiveness for the advertiser. As a result, the top of the list will be the ads which will have a balance for both sides – advertisers and partners.