Calculating items purchased within a campaign

Published July 29, 2022
Modules
Difficulty
Selected Clients
ccc logosharafdg logo

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:

  1. Getting the list of clicked products.
  2. Getting the timestamp of the first visit to the product page.
  3. Getting the list of the order IDs after clicking the recommendation.
  4. Multiply the product price by the product quantity.
  5. 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.

  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. Select Consider only distinct occurrences of the event parameter.
  5. In the Size field, enter the number of returned SKUs.
  6. Select the page.visit event.
  7. Select the product:retailer_part_no parameter.
  8. Select the url parameter.
  9. Select the Contain logical operator.
  10. 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:
    Filled settings of the aggregate
    ID of recommendation campaign in URL
  11. Save the aggregate.
Last visited recommendation aggregate
Last visited recommendation 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.

  1. Go to Analytics icon Analytics > Aggregates > Create aggregate.
  2. As the aggregate type, select Profile.
  3. Click Analyze profiles by and select First.
  4. Select the page.visit event.
  5. Select the TIMESTAMP parameter.
  6. Select the url address parameter.
  7. Select the Contain logical operator.
  8. In the text field, enter the ID of the recommendation campaign.
  9. Save the aggregate.
Configuration of the aggregate
Time of the first visit to the product of the recommendation campaign

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.

  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. Select Consider only distinct occurrences of the event parameter.
  5. Select the product.buy event.
  6. Select the $orderID parameter.
  7. Select the $sku parameter.
  8. Select the IN ARRAY logical operator.
  9. Select the aggregate you created in the Getting the list of visited products step.
  10. Save the aggregate.
Configuration of the aggregate
The list of products clicked in the recommendation

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.

  1. Go to Analytics icon Analytics > Expressions > New expressions.
  2. From the Expression for list, select Events.
  3. Select the product.buy event.
  4. On the dashboard, click the Select button and select Event attribute.
  5. On the list, find $finalUnitprice or other parameter that signifies the actual transaction value.
  6. Click the plus button and select Event attribute.
  7. On the list, find $quantity or other parameter that signifies the quantity of the product.
  8. Change the mathematical sign between the attributes from the plus sign to times sign (x).
  9. Save the expression.
Configuration of the expression
Configuration of 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.
Click to see the metric for the number of 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.

  1. Go to Analytics 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 following parameters:
    1. Add the $sku parameter.
      1. Select the In operator.
      2. Keep clicking the icon next to the logical operator until you get Choose value icon.
      3. Select the aggregate that returns the list of visited products.
    2. Add the TIMESTAMP parameter (available in the Specials tab).
      1. Select the Date operator.
      2. Select the More than option.
      3. Keep clicking the icon next to the logical operator until you get Choose value icon
      4. Select the aggregate that returns the timestamp of the first product visit.
  6. Select the date range of the metric (for example, last 30 days).
  7. Save the metric by clicking Save.
Configuration of the metric
Configuration of the metric

Click to see the metric for the sum of products bought after clicking a campaign

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.

Tip: You can duplicate the metric that calculates the number of products bought after clicking a product, change the aggregator from Count to Sum and use the expression that multiplies the price by the quantity.
  1. Go to Analytics icon Analytics > Metrics > New metric.
  2. Enter the name of the metric.
  3. As the aggregator type, select Sum.
  4. Select the product.buy event.
  5. Add the following parameters:
    1. The expression that multiplies the product price by product quantity.
      1. Select the $sku parameter.
      2. Select the In operator.
      3. Keep clicking the icon next to the logical operator until you get Choose value icon.
      4. Select the aggregate that returns the list of visited products.
    2. Add the TIMESTAMP parameter (available in the Specials tab).
      1. Select the Date operator.
      2. Select the More than option.
      3. Keep clicking the icon next to the logical operator until you get Choose value icon
      4. Select the aggregate that returns the timestamp of the first product visit.
  6. Select the date range of the metric (for example, last 30 days).
  7. Save the metric by clicking Save.
Configuration of the metric
Configuration of the metric

Click to see the metric for the number of transactions with the products bought after clicking a campaign

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.

  1. Go to Analytics icon Analytics > Metrics > New metric.
  2. Enter the name of the metric.
  3. Leave the Aggregator to default (Count).
  4. Select the transaction.charge event.
  5. Add the following parameters:
    1. Add the $orderID parameter.
      1. Select the In operator.
      2. Keep clicking the icon next to the logical operator until you get Choose value icon
      3. Select the aggregate that returns the list of the order IDs after clicking the recommendation.
    2. Add the TIMESTAMP parameter (available in the Specials tab).
      1. Select the Date operator.
      2. Select the More than option.
      3. Keep clicking the icon next to the logical operator until you get Choose value icon
      4. Select the aggregate that returns the timestamp of the first product visit.
  6. Select the date range of the metric (for example, last 30 days).
  7. Save the metric by clicking Save.
Configuration of the metric
Configuration of the metric

Click to see the metric for the sum of transactions with the products bought after clicking a campaign

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.

Tip: If you have already created a metric for the number of transactions with the products bought after clicking a campaign, you can duplicate it and change the aggregator type and use the totalAmount parameter.
  1. Go to Analytics icon Analytics > Metrics > New metric.
  2. Enter the name of the metric.
  3. As the Aggregator type, select Sum.
  4. Select the transaction.charge event.
  5. Add the following parameters:
    1. Add the $totalAmount parameter.
      1. Select the In operator.
      2. Keep clicking the icon next to the logical operator until you get Choose value icon
      3. Select the aggregate that returns the list of the order IDs after clicking the recommendation.
    2. Add the TIMESTAMP parameter (available in the Specials tab).
      1. Select the Date operator.
      2. Select the More than option.
      3. Keep clicking the icon next to the logical operator until you get Choose value icon
      4. Select the aggregate that returns the timestamp of the first product visit.
  6. Select the date range of the metric (for example, last 30 days).
  7. Save the metric by clicking Save.
Configuration of the metric
Configuration of the metric

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:

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