Calculating items purchased within a campaign
Thanks to the parameters in the URL, we can track the behavior of customers after interacting with a given campaign. In this use case, we will show an example of analyses related to AI recommendations, but in general, the same principles can be applied to create an analysis for any campaign where these parameters in the URL are placed.
It helps us check the effectiveness of recommendations and monitor the purchases (exact number of products bought after clicking and their total value). This use case describes the process of creating aggregates, metrics and other analyses that count purchases based on the URL parameter with the ID of the AI recommendation.
Prerequisites
- A tracking code implemented in the source of your website.
- Send information about transactions through API or SDK.
- Implement OG Tags on your website.
- Implement AI recommendation on your website or, in case you want to analyze different type of campaign, add unique parameters to the URL after clicking it, which will allow you to analyze the campaign results.
Process
This use case contains the following steps which must be performed in the given order:
- Getting the list of clicked products.
- Getting the timestamp of the first visit to the product page.
- Getting the list of the order IDs after clicking the recommendation.
- Multiply the product price by the product quantity.
- Create metrics that calculate:
- The number of products bought after clickng the recommendation
- The value of products bought after clicking the recommendation
- The number of transactions with the products bought after clicking the recommendation
- The value of transactions with the products bought after clicking the recommendation
Getting the list of clicked products
Create an aggregate that returns the SKUs of the clicked items (from a particular recommendation campaign). You will use these SKUs later to check if they occured in the transactions that occurred after clicking at a certain time.
In this use case, we analyze clicking a product from a given AI recommendation based on the page.visit
event and uri
parameter (URL of the website). This parameter contains ?snrai_campaign=XXX
part, where XXX
is the ID of AI recommendation that was clicked. The ?snrai_campaign
parameter it is added to the URL automatically when implementing AI recommendation.
The analysis is also based on the ID of the clicked product which is stored in the retailer_part_no
parameter. However, sometimes clicking a product does not transfer directly to the product page, so it is not possible to add parameters to the URL, especially in the case of “Add to cart” buttons placed directly in the product frame. In such case instead of relying on the page.visit
event, you should implement a custom event. Such an event must contain the AI recommendation ID and the product ID that was clicked in its parameters. Then you will be able to rely your analyses on this custom event.
- Go to Analytics > Aggregates > Create aggregate.
- As the aggregate type, select Profile.
- Click Analyze profiles by and select Last Multi.
- Select Consider only distinct occurrences of the event parameter.
- In the Size field, enter the number of returned SKUs.
- Select the page.visit event.
- Select the product:retailer_part_no parameter.
- Select the url parameter.
- Select the Contain logical operator.
- In the text field, enter the ID of the recommendation campaign.
Tip: You can find it in the URL of the product from the recommendation: - Save the aggregate.
Getting the timestamp of the first visit
You must get the time of the first click at the product from recommendation campaign. To do so, we use the TIMESTAMP
parameter and the ID of the recommendation campaign which is visible in the clicked link. Timestamp allows you to define the period from which transactions should be taken into account, and also those transactions which occurred after clicking the campaign.
- Go to Analytics > Aggregates > Create aggregate.
- As the aggregate type, select Profile.
- Click Analyze profiles by and select First.
- Select the page.visit event.
- Select the TIMESTAMP parameter.
- Select the url address parameter.
- Select the Contain logical operator.
- In the text field, enter the ID of the recommendation campaign.
- Save the aggregate.
Getting the list of the order IDs after clicking the recommendation
Create an aggregate that returns the order IDs of the products included in the first aggregate you prepared. It allows you to identify the transactions that included the products clicked from the specific campaign and those transactions which took place just after the click.
- Go to Analytics > Aggregates > Create aggregate.
- As the aggregate type, select Profile.
- Click Analyze profiles by and select Last Multi.
- Select Consider only distinct occurrences of the event parameter.
- Select the product.buy event.
- Select the $orderID parameter.
- Select the $sku parameter.
- Select the IN ARRAY logical operator.
- Select the aggregate you created in the Getting the list of visited products step.
- Save the aggregate.
Multiply the product price by the product quantity
Create an event expression that multiplies the final price of the product and its quantity. At the same time you enrich the parameters of the product.buy
event.
- Go to Analytics > Expressions > New expressions.
- From the Expression for list, select Events.
- Select the product.buy event.
- On the dashboard, click the Select button and select Event attribute.
- On the list, find $finalUnitprice or other parameter that signifies the actual transaction value.
- Click the plus button and select Event attribute.
- On the list, find $quantity or other parameter that signifies the quantity of the product.
- Change the mathematical sign between the attributes from the plus sign to times sign (
x
). - Save the expression.
Create metrics
Prepare metrics based on the three aggregates you created in previous steps. Including the aggregates in metrics lets you calculate:
- the number of products purchased after clicking in the campaign,
- the total value of products purchased after clicking in the campaign,
- the number of transactions that include the products bought after clicking the campaign,
- the total value of transactions that include the products bought after clicking the campaign.
In this metric, you check the number of products by using in the metric formula the aggregate that returns the SKU of the products viewed within a campaign.
Additionally, narrow down the results by using the timestamp parameter. Set the time stamp to include the purchases after the first click at the product in the campaign. For that purpose, use the aggregate that calculates the timestamp of the first product visit.
- 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 following parameters:
- Add the $sku parameter.
- Select the In operator.
- Keep clicking the icon next to the logical operator until you get .
- Select the aggregate that returns the list of visited products.
- Add the TIMESTAMP parameter (available in the Specials tab).
- Select the Date operator.
- Select the More than option.
- Keep clicking the icon next to the logical operator until you get
- Select the aggregate that returns the timestamp of the first product visit.
- Add the $sku parameter.
- Select the date range of the metric (for example, last 30 days).
- Save the metric by clicking Save.
This metric returns the total sum of products bought after clicking a campaign. The metric uses the expression that multiplies the product price by the product quantity.
- Go to Analytics > Metrics > New metric.
- Enter the name of the metric.
- As the aggregator type, select Sum.
- Select the product.buy event.
- Add the following parameters:
- The expression that multiplies the product price by product quantity.
- Select the $sku parameter.
- Select the In operator.
- Keep clicking the icon next to the logical operator until you get .
- Select the aggregate that returns the list of visited products.
- Add the TIMESTAMP parameter (available in the Specials tab).
- Select the Date operator.
- Select the More than option.
- Keep clicking the icon next to the logical operator until you get
- Select the aggregate that returns the timestamp of the first product visit.
- The expression that multiplies the product price by product quantity.
- Select the date range of the metric (for example, last 30 days).
- Save the metric by clicking Save.
This metric is based on the transaction.charge
event (this event collects an array of products included in the transaction). The metric reuses the aggregate that returns the list of products bought after clicking the campaign to check if the order ID of the product is included in the transaction. The scope of the metric is narrowed down by the aggregate that returns the timestamp of the first visit at the product page.
- Go to Analytics > Metrics > New metric.
- Enter the name of the metric.
- Leave the Aggregator to default (Count).
- Select the transaction.charge event.
- Add the following parameters:
- Add the $orderID parameter.
- Select the In operator.
- Keep clicking the icon next to the logical operator until you get
- Select the aggregate that returns the list of the order IDs after clicking the recommendation.
- Add the TIMESTAMP parameter (available in the Specials tab).
- Select the Date operator.
- Select the More than option.
- Keep clicking the icon next to the logical operator until you get
- Select the aggregate that returns the timestamp of the first product visit.
- Add the $orderID parameter.
- Select the date range of the metric (for example, last 30 days).
- Save the metric by clicking Save.
This metric is based on the transaction.charge
event (this event collects an array of products included in the transaction). The metric reuses the aggregate that returns the list of products bought after clicking the campaign to check if the order ID of the product is included in the transaction. The scope of the metric is narrowed down by the aggregate that returns the timestamp of the first visit at the product page.
totalAmount
parameter.- Go to Analytics > Metrics > New metric.
- Enter the name of the metric.
- As the Aggregator type, select Sum.
- Select the transaction.charge event.
- Add the following parameters:
- Add the $totalAmount parameter.
- Select the In operator.
- Keep clicking the icon next to the logical operator until you get
- Select the aggregate that returns the list of the order IDs after clicking the recommendation.
- Add the TIMESTAMP parameter (available in the Specials tab).
- Select the Date operator.
- Select the More than option.
- Keep clicking the icon next to the logical operator until you get
- Select the aggregate that returns the timestamp of the first product visit.
- Add the $totalAmount parameter.
- Select the date range of the metric (for example, last 30 days).
- Save the metric by clicking Save.
What’s next
You can display created metrics on the dashboard, which help you present them in useful and readable form.
Check the use case set up on the Synerise Demo workspace
You can check the created metrics directly in Synerise Demo workspace:
- Number of products bought after clicking the campaign
- The sum of products bought after clicking a campaign
- The number of transactions with the products bought after clicking a campaign
- The sum of transactions with the products bought after clicking a campaign
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.