Calculate transactions with the use of promotional codes
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
- Implement a tracking code.
- Implement transactional events.
- Create and activate a promotion.
Process
In this use case, you will go through the following steps:
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.
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.
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.
- Go to Analytics > Expression > New expression.
- Enter the name of the expression.
- Set the Expression for option to Event.
- From the dropdown list, select transaction.charge.
- In the Formula definition section of the page, click Select.
Result: A dropdown list appears. - From the list that opens, select Function > Concat.
- In the brackets, click the left Select button and from the list, select again Function > Concat.
- In the brackets, click the left and right Select button from the list and select Constant with value
0
. - After the brackets click the Select button and from the list select Function > Regexp.
- In the brackets, click the left Select button and from the list, select Event attribute loyalRewards.
- Click the right Select button and from the list, select Constant with value
(?<="promoId":")(.+?)(?=\"|$)
. - Save the expression.
Create an aggregate
In this part of the process, create an aggregate that returns the id of the assigned promotion from promo3 parameter.
- Go to Analytics > Aggregates > Create aggregate.
- As the aggregate type, select Profile.
- Click Analyze profiles by and select Last Multi.
- In the Size field choose how many values you would like to return.
- Select Consider only distinct occurrences of the event parameter.
- Select the handbill.assign event.
- Select the promo3 parameter.
- Select the id and variantName parameter for which you want to get results.
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.
- Go to Analytics > Metrics > New metric.
- Enter the name of the metric.
- Leave the Aggregator at default (Count).
- Select the product.buy event.
- Add the ”promoId z loyalRewards” parameter (additional parameter created with expression.
- Select In operator.
- Keep clicking the icon next to the logical operator until you get Choose value button.
- Select the aggregate that returns last multi assigned handbills created in this step.
- Add a filter with people who had a handbill.assign event from a specific campaign id.
- Select the date range of the metric.
- Save the metric.
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.