# Personalized Advertising in E-Commerce: Using Clickstream Data to Target High-Value Customers
## 3 Methodology for Calibrating the Customer's Value Metric
### The Algorithm of Advertising Campaign Assignment  
In order to accumulate the changes of customer's merit (CM) index, we suggest to use a separate Customer DB (CDB) file. The CDB file contains a number of variables that provide valuable insights into the behavior characteristics of customers. These variables include the customer's unique ID, their current CM index value, and the date/time of their last access. Additionally, the CDB tracks the customer's browsing behavior, including the last items viewed with their prices, as well as the count and value of items they have purchased. In Figure 4, a list of all the CDB variables with assigned names is provided.  
Moreover, the CDB contains additional information that can further support customer analytics. This includes whether the customer has a registration ID, the type of browser they are using, the operating system they are on, and other relevant characteristics. This information is used to set initial CM index values, determine a limit value L and provide a more comprehensive understanding of each customer's behavior and preferences. By analyzing these variables, businesses can better tailor their marketing strategies and optimize their e-commerce platforms to improve customer satisfaction and drive sales.  
The algorithm for calculating the customer index (CM) involves increasing it after each customer action (visited link) according the Tracks DB file records until it reaches a limit value (L), at which point an advertising campaign is assigned.  
The value of L is then returned to the personalized initial value of L. To assign the next advertising campaign, the customer's CM must once again reach the limit value (L).  
Figure 4: CM computing and advertising campaign assignment algorithm.  
If a customer has not been active on the e-shop for a significant period of time, their CM value should decrease. We suggest their CM index is decreased by 1% for each day of inactivity.  
For more detailed explanation of the CM computing algorithm, please refer to Figure 4. In the diagram of the algorithm, we use the file variable names shown at the top right on Figure 4.  
Figure 4, illustrates the procedure of the customer index (CM) computing algorithm. It involves the use of a coefficient k to decrease the CM index value. When k is set to 0.01, it implies that the CM index will be reduced by 1% for each day since the customer's last visit to the e-shop.  
If a customer makes a new visit to the e-shop, but their CM index exceeds the limit value L and an advertising campaign has already been assigned, no new campaign is provided. Additionally, the CM value is decreased by L. Similarly, if a customer has just made a checkout, an advertising campaign is not assigned.  
As we can see from Figure 4, the algorithm follows and register in the Customers DB file the 3 last products the user was interested in, their price and the total value and count of all purchases. This does not affect the CM index value, but can be used to determine the nature of the advertisement campaign.  
Our algorithm let as to choose the advertising campaign limit value L depending on how much money we want to spend on this company. If we select L at level 0, advertising will be assigned to all customers who visit the e-shop site. By increasing the value of L, we will reduce the customers number included in advertising company and, at the same time, the budget required for this. How to determine the optimal value of L that ensures the minimum advertisement company price and the maximum attraction of customers is a rather complex task that requires extensive calculations on click-stream data for each individual e-shop.  
In the next section, using 2 real e-shops click-stream data, we will demonstrate the performance of our proposed algorithm for different values of limit value L. The number of advertising campaigns assigned to customers in e-shop, as well as the size of the target group of e-shop surfers, is adjusted based on the dynamics of their CM index.