Calculating items purchased within a campaign

This article contains instruction on preparing analyses that calculate the number of products bought after clicking them within a campaign, for example:

  • AI recommendation,
  • email
  • web push
  • dynamic content
Note: The use case below contains the analyses for the products bought after clicking AI recommendations.

Required steps


This use case contains the following steps which must be performed in the given order:

  1. Getting the list of visited products
  2. Getting the timestamp of the first visit to the product page
  3. Getting the list of the products bought 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

Prerequisites


  • A tracking code implemented in the source of your website to collect events

  • Send information about transactions through API, periodic imports or Data Layer

  • Only for AI Recommendations: Make sure your page.visit event contains sku parameter and if it matches the sku in the product.buy event.

  • Only for other campaign types: Add a custom event that contains the SKU parameter. The exemplary event is available below:

    SR.event.trackCustomEvent('product.click', {
                    'product_sku': 'xxx',
                    'type': 'Synerise',
                    'device': (SyneriseTC.os.mobile ? 'mobile' : 'desktop'),
                    'campaign_name': 'xxx',
                    'placement': 'xxx',
                    'typeClick': 'xxx',
                    'title': 'xxx',
                    'campaignId': 'xxx'
                },'Product clicked'); 
        

Events and parameters


The table below lists and explains the events and their parameters which are used in this use case.

Important: The analyses in this use case contain events and parameters which names may slightly differ from the names in your business profile (especially parameter names).
Event name/
Parameter name
Description Additional info
page.visit This event is signifies a visit to a
tracked website.
This is a default event that is
generated as a result of implementing
a tracking code to a website.
product.buy
(Bought product)
This event signifies a purchase of
a product within one transaction (for
example, when a user buys 2 products,
two product.buy events are generated).
This event is generated as a result of
sending information to Synerise
through API, periodic imports to
Synerise or Data Layer after
a purchase of an item.
transaction.charge
(Transaction)
This event signifies a transaction. This event
collects an array of products included
in the transaction.
This event is generated as a result of
sending information to Synerise
through API, periodic imports to
Synerise or through Data Layer after a
purchase of items.
$finalUnitPrice This is the final price a customer must pay for
an item.
This is a parameter of the product.buy
event. It is
available in Synerise after sending
it through API, periodic imports or
Data Layer.
$orderID This is the ID of the order within
which a product was purchased.
This is a parameter of the product.buy
and transaction.charge events. It is
available in Synerise after sending
it through API, periodic imports or
Data Layer.
product:retailer_part_no This is an OG tag which includes the
ID of the product
This is a parameter of the
page.visit event. To be able to
use it, you must implement this
parameter in the OG tags on
the tracked website.
$quantity This is the number of items of a specific
product.
This is a parameter of the product.buy event. It is
available in Synerise after sending
it through API, periodic imports or
Data Layer.
$sku This is the ID of the product. This is a parameter of the product.buy event.
It is available in Synerise after sending
it through API, periodic imports or
Data Layer.
TIMESTAMP This parameter allows to point the date
when something happened.
It’s available in every business
profile.
$totalAmount This is the total sum of a transaction. This is a parameter of the transaction.charge event. It is
available in Synerise after sending
it through API, periodic imports or
Data Layer.
uri This parameter signifies the URI of a tracked
website.
This is a default parameter of the
page.visit event. It may available for
other events as well.

Getting the list of visited products


Create an aggregate that returns the SKUs of the visited items (from a particular recommendation campaign).

Configuration of the aggregate
Last visited recommendation aggregate
  1. Go to Analytics > Aggregates > New aggregate.
  2. As the type of the aggregate select LAST_MULTI.
  3. Select Consider only unique occurrence of the event parameter.
  4. In the Size field, enter the number of returned SKUs.
  5. Select the page.visit event.
  6. Select the product:retailer_part_no parameter.
  7. Select the uri parameter.
  8. Select the Contain logical operator.
  9. 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
  10. Save the aggregate.

Getting the timestamp of the first visit


You must get the time of the first click at the product (visit of the product in the recommendation campaign). This time, instead of the SKU, use the timestamp parameter and the ID of the recommendation campaign.

Configuration of the aggregate
Time of the first visit to the product of the recommendation campaign
  1. Go to Analytics > Aggregates > New aggregate.
  2. As the type of the aggregate select FIRST.
  3. Select the page.visit event.
  4. Select the TIMESTAMP parameter.
  5. Select the uri parameter.
  6. Select the Contain logical operator.
  7. In the text field, enter the ID of the recommendation campaign.
  8. Save the aggregate.

Getting the list of the products bought after clicking the recommendation


Create an aggregate that returns the order ID of the products included in the first aggregate you prepared.

Configuration of the aggregate
The list of products clicked in the recommendation
  1. Go to Analytics > Aggregates > New aggregate.
  2. As the type of the aggregate select LAST_MULTI.
  3. Select Consider only unique occurrence of the event parameter.
  4. Select the product.buy event.
  5. Select the $orderID parameter.
  6. Select the $sku parameter.
  7. Select the IN logical operator.
  8. Select the aggregate you created in the Getting the list of visited products step.
  9. 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.

Configuration of the expression
Configuration of the expression
  1. Go to 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.

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 purchased products,
  • 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.

Configuration of the metric
Configuration of the metric
  1. Go to 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.

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.
Configuration of the metric
Configuration of the metric
  1. Go to 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.

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.

Configuration of the metric
Configuration of the metric
  1. Go to 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 bought 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.

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.
Configuration of the metric
Configuration of the metric
  1. Go to 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 bought 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.

FAQ


How to create analyses for other events and campaign types?

  1. Add a custom event, for example:

        SR.event.trackCustomEvent('product.click', {
                        'product_sku': 'xxx',
                        'type': 'Synerise',
                        'device': (SyneriseTC.os.mobile ? 'mobile' : 'desktop'),
                        'campaign_name': 'xxx',
                        'placement': 'xxx',
                        'typeClick': 'xxx',
                        'title': 'xxx',
                        'campaignId': 'xxx'
                    },'Product clicked'); 
            
  2. Create aggregates based on this event as described in this article.

Configuration of the aggregate
Aggregate that returns a list of visited products from one campaign

Can I use other parameter instead of SKU?

Yes, you can use other parameters that are shared between events you will use in your analyses. For example, when you want to use the page.visit and product.buy event, if you pass the image parameter in both events (they don’t have to have the same name, but they must have the same value), you can use it instead of SKU.

😕

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.