Calculate transactions with the use of promotional codes

Published March 22, 2022
Modules
Difficulty
Selected Clients
sharafdg logo

To implement effective promotional campaigns, it is important to carefully analyze the results of past campaigns, draw conclusions and use this knowledge in the future. This use case describes how to calculate the number of transactions with the use of promotional codes.

Prerequisites


Process


In this use case, you will go through the following steps:

  1. Prepare a regular expression.
  2. Create an expression.
  3. Create an aggregate.
  4. Create a metric.

Prepare a regular expression


When a promotion is assigned to a customer, the event appears on the customer’s profile (for example, a handbill.assign event). This event contains a parameter (in this use case, promo3) with the promotion number.

If a customer uses the promotion code during the purchase, a transaction event appears on the customer’s profile with the parameter that contains the promotion number as well. However, the values of these parameters are slightly different for the two events.

In the transaction event, two zeros at the beginning of the promotion number are deducted, so the challenge is to turn these values into an identical format as it is in the handbill.asign event.

Comparison of the handbil.assign and transaction event
Comparison of the handbil.assign and transaction event

For this purpose, prepare a regular expression that will extract the number of promotion from the parameter of the transaction event. In our use case, the regular expression will take the following form (?<="promoId":")(.+?)(?=\"|$). You will use it in the next part of the procedure.

The regular expression matches a promoID in an example value of the transaction event parameter
The regular expression matches a promoID in an example value of the transaction event parameter

Create an expression


Create an expression for the transaction event. Using the Concat function in the expression, add two zeros to the loyalRewards parameter (which contains the number of the promotion). As a result, the two zeros are added at the beginning of the promotion number and the expression returns the number of promotion which matches the number of promotion in the handbill.asign event.

  1. Go to Profiles icon Analytics > Expression > New expression.
  2. Enter the name of the expression.
  3. Set the Expression for option to Event.
  4. From the dropdown list, select transaction.charge.
  5. In the Formula definition section of the page, click Select.
    Result: A dropdown list appears.
  6. From the list that opens, select Function > Concat.
  7. In the brackets, click the left Select button and from the list, select again Function > Concat.
  8. In the brackets, click the left and right Select button from the list and select Constant with value 0.
  9. After the brackets click the Select button and from the list select Function > Regexp.
  10. In the brackets, click the left Select button and from the list, select Event attribute loyalRewards.
  11. Click the right Select button and from the list, select Constant with value (?<="promoId":")(.+?)(?=\"|$).
  12. Save the expression.
Expression adding zeros to the parameter
Expression adding zeros to the parameter

Create an aggregate


In this part of the process, create an aggregate that returns the id of the assigned promotion from promo3 parameter.

  1. Go to Analytics icon Analytics > Aggregates > Create aggregate.
  2. As the aggregate type, select Profile.
  3. Click Analyze profiles by and select Last Multi.
  4. In the Size field choose how many values you would like to return.
  5. Select Consider only distinct occurrences of the event parameter.
  6. Select the handbill.assign event.
  7. Select the promo3 parameter.
  8. Select the id and variantName parameter for which you want to get results.
An aggregate that will return the most recently assigned promotions
An aggregate that will return the most recently assigned promotions

Create a metric


In this step you will create a metric that calculates the number of transactions made by customers who had the promotional code assigned to their profile and used it during the purchase process.

  1. Go to Profiles icon Analytics > Metrics > New metric.
  2. Enter the name of the metric.
  3. Leave the Aggregator at default (Count).
  4. Select the product.buy event.
  5. Add the ”promoId z loyalRewards” parameter (additional parameter created with expression.
  6. Select In operator.
  7. Keep clicking the icon next to the logical operator until you get Choose value button.
  8. Select the aggregate that returns last multi assigned handbills created in this step.
  9. Add a filter with people who had a handbill.assign event from a specific campaign id.
  10. Select the date range of the metric.
  11. Save the metric.
Metrics configuration
Metrics configuration

Check the use case set up on the Synerise Demo workspace


You can check the configuration of every element of this process directly in Synerise Demo workspace:

If you don’t have access to the Synerise Demo workspace, please leave your contact details in this form, and our representative will contact you shortly.

Read more


😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker