Daily additional points for the fastest buyers

Published October 21, 2022
Modules
Difficulty
Selected Clients
zabka logo

Synerise offers endless possibilities for creating business loyalty scenarios. One of them may be a campaign that ends after a specific number of redemptions and revokes every day. It can increase the traffic in your mobile app. Combining this with additional loyalty points may bring you new customers.

In this use case, you will create a scenario that awards customers with additional 1500 loyalty points for the purchase of a soda. The promotion works every day for the first 1000 buyers. The mechanism controls the number of purchases and informs the mobile app user if they can still get the additional points, or if they are late and need to try again on another day.

Mobile view of an example of promotion content

Prerequisites


Security configuration


Before you start working with this module, if you are a Synerise customer or partner, consider reading the section about denylisting events. This natively accessible configuration will allow you to manage the restrictions in points management that may help you prevent fraud. 

Process


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

  1. Create a metric that calculates the number of purchases of soda on the current day.
  2. Create a catalog which stores the current information for the customers: whether they can get additional points or not.
  3. Create an automation updating the catalog content and awarding points.
  4. Create an automation updating the catalog content to the default value. Thanks to this, the mechanism will reset the information about promotion availability every day.
  5. Create a document with a catalog content which sends the content of the catalog with information for the customer to the mobile app.

Create a metric


In this part of the process, you will create a metric which counts how many times the product on promotion was bought on the current day.

  1. Go to Profiles icon Analytics > Metrics > New metric.
  2. Enter the name of the metric.
  3. As the metric type, select Simple metric.
  4. Leave the Aggregator at default (Count).
  5. As the occurrence type, set All.
  6. From the Choose event dropdown list, select the product.buy event.
  7. Click the where icon button.
  8. From the Choose parameter dropdown list, select $sku.
  9. From the Choose operator dropdown list, select Equal.
  10. As the value of the operator, add the SKU of the product for which you award the additional points.
  11. Open the time range settings by clicking the calendar icon.
    1. In the Relative date range section, choose Today.
    2. Click Apply.
  12. Click Save.
The view of the metric configuration
Configuration of the metric

Create a catalog


In this part of the process, you need to create a catalog, which will store the current information about promotion availability. At later stages of the process, this catalog will be updated on the basis of how many soda transactions have been made on a given day. Also, it will be separately updated at midnight every day when resetting the daily redemption counter.

  1. Prepare a CSV file of your promotion content, according to requriements. Below is the sample file used in this article. It consists of two columns, where the first is a message that will be shown to customers and the second is the key of the promotion.
    copy;key
    Buy a soda and get extra loyalty points!;copyKey
    
    Note: You can use this file in your implementation, after changing the message to your business needs.
  2. Go to Data Management icon Data Management > Catalogs > New Catalog.
  3. Enter the name of the catalog.
  4. Click Apply to confirm. The catalog will appear on the list.
  5. Click on the created catalog.
  6. In the upper right corner, click Import CSV.
  7. Click the Upload file button.
  8. Upload the CSV file you prepared.
  9. In the Order key field, type the name of the column whose values are treated as the key.
    In our example, it’s key
  10. Click Import.
The view of the CSV file upploaded to catalog
Configuration of the catalog

Create an automation updating the catalog content and awarding points


In this part, you will create a workflow which triggers when the product for which you assign additional points is bought. If the result of the metric created earlier is greater than 1000, it will update the catalog with the message that the promotion is over today. If the metric’s result is smaller than 1000, it will grant extra points to the customer.

  1. Go to Automation icon Automation > Workflows > New workflow.
  2. Enter the name of the workflow.

Define the trigger node


At this stage, you will configure the conditions that trigger the workflow.

  1. Add the first node - Profile Event. In the node configuration:
    1. From the Choose event dropdown list, choose the product.buy event.
    2. Click where icon button.
    3. From the Choose parameter dropdown list, select $sku.
    4. From the Choose operator dropdown list, select Equal.
    5. As the value of the operator, add the SKU of the product for which you want to award additional points.
  2. Click Apply.
The view of the Profile Event node configuration
Configuration of the Profile Event node

Define the Outgoing Integration node


In the Outgoing Integration node, you will create a webhook calculating the metric from the previous step. The continuation of the workflow will depend on the result of the metric.

  1. After the trigger node, add Outgoing Integration.
  2. In Definition section, choose the Custom webhook tab.
  3. In the Webhook name, field enter a name for the webhook. In this case Metric recalculation.
  4. Select the POST method. 3. In the URL of the endpoint, enter https://api.synerise.com/analytics-backend/analytics/v3/metrics/ID/recalculate, where the ID is the ID of your metric created earlier.
  5. In the Authorization section, select by API key as your method of authorization.
    1. From the dropdown list below, select your API key.
  6. Click Apply.
The view of the Outgoing Integration node configuration
Configuration of the Outgoing Integration node

Define two Event Filter nodes on the metric result


In this step, you will split the automation path, so different actions can happen according to the metric result created earlier. If the result is greater than 1000, it will update the catalog with copy that today the promotion is over. If the metrics result is smaller than 1000, it will grant extra points to the customer.

  1. Click THEN on the Outgoing Integration node, and add Split Path.
  2. Add two Event Filter nodes.
  3. Configure the first Event Filter node:
    1. Enter the meaningful name of the node, ex. when promotion is over on the current day.
    2. From the Choose event dropdown list, choose the webhook.response event.
    3. Click where icon button.
    4. From the Choose parameter dropdown list, select name.
    5. From the Choose operator dropdown list, select Equal.
    6. As the value of the operator, add the name of the webhook created earlier.
      In this case, it’s Metric recalculation.
    7. Click the where icon button.
    8. From the Choose parameter dropdown list, choose body.result.
    9. From the Choose operator dropdown list, select More than (Number).
    10. As the value of the operator, type 1000.
    11. Click Apply.
    The view of the Event Filter for metric result grater than 1000
    Configuration of the first Event Filter node
  4. Configure the second Event Filter node:
    1. Enter the meaningful name of the node, ex. when promotion still lasts on the current day.
    2. From the Choose event dropdown list, choose the webhook.response event.
    3. Click where icon button.
    4. From the Choose parameter dropdown list, select name.
    5. From the Choose operator dropdown list, select Equal.
    6. As the value of the operator, add the name of the webhook created earlier.
      In this case, it’s Metric recalculation.
    7. Click where icon button.
    8. From the Choose parameter dropdown list, choose body.result.
    9. From the Choose operator dropdown list, select Less or equal to (Number).
    10. As the value of the operator, type 1000.
    11. Click Apply.
    The view of the Event Filter for metric result less than 1000
    Configuration of the second Event Filter node

Define the Outgoing Integration node changing the catalog copy


This Outgoing Integration node will be connected to the first Event Filter node (where the condition is that the metric result is above 1000). When the number of sold sodas exceeds 1000, the automation will update the text in the catalog to inform that the offer is no longer available for the current day and the customer will receive such information in the mobile app.

  1. To the first Event Filter, add the Outgoing Integration node.

  2. In the Definition section, choose the Custom webhook tab.

  3. In the Webhook name, field enter name for the webhook. In this case, it’s change.documentCopy.

  4. Select the POST method. 3. In the URL of the endpoint, enter https://api.synerise.com/catalogs/bags/ID/items, where the ID is the ID of your catalog created earlier.

  5. Enter the request body. For the form used in this case, the body is as follows:

        {
            "value": {
                "key": "copyKey",
                "copy": "Today, the use limit on this offer has already been reached 😞 Come back tomorrow!"
                },
            "itemKey": "copyKey"
        }
        
    Note: You can use this JSON code in your implementation, but change the names of the columns within the catalog and copy content according to your business needs.
  6. In the Authorization section, select by API key as your method of authorization.

    1. From the dropdown list below, select your API key.
  7. Click Apply.

  8. Add the End node.

Define Generate Event node


This Generate event node will be connected to the second Event Filter node. When the number of sold sodas is below 1000, the automation will generate an event granting extra loyalty points to the customers.

  1. To the second Event Filter, add the Generate Event node.

  2. In the Define event section:

    1. As the Event name choose points.upcharge.

    2. In the Label field, type extra points for buying a soda.

    3. Enter the request body. For the form used in this case, the body is as follows:

              {
              "name": "Extra points for buying a soda",
              "points": "1500"
              }
              
  3. Click Apply.

    The view of the Generate Event node configuration
    Configuration of the Generate Event node
  4. Add the End node.

Result:

The view of the automation updating the catalog copy or awarding points
Automation updating the catalog copy or awarding points

Create an automation updating the catalog content to the default value


In this part of the process, you will create a workflow which triggers at midnight every day and changes the message in the catalog to its default value: information that you can buy a soda and get extra loyalty points.

  1. Go to Automation icon Automation > Workflows > New workflow.
  2. Enter the name of the workflow.
  3. As the trigger node, add Scheduled Run.
  4. In the configuration of the node:
    1. Leave the Run trigger setting at default (all time).
    2. In the Repeat runs section, set your Timezone, then choose Everyday and set the time to 0:00.
    3. Click Apply.
  5. Add the Outgoing Integration node.
  6. In the configuration of the node:
    1. In the Definition section, choose the Custom webhook tab.

    2. In the Webhook name, field enter name for the webhook. In this case, it’s change.documentCopy.

    3. Select the POST method.

    4. In the URL of the endpoint, enter https://api.synerise.com/catalogs/bags/ID/items, where the ID is the ID of your catalog created earlier.

    5. Enter the request body. For the form used in this case, the body is as follows:

              {
                  "value": {
                      "key": "copyKey",
                      "copy": "Buy a soda and get extra 1500 loyalty points! 
                      Take advantage of this offer while you still can!"
                      },
                  "itemKey": "copyKey"
              }
              
      Note: You can use this JSON code in your implementation, but change the names of the columns within the catalog and copy content according to your business needs.

    6. In the Authorization section, select by API key as your method of authorization.

    7. From the dropdown list below, select your API key.

    8. Click Apply.

  7. Add the End node.

Result:

The view of the automation updating the catalog to the default value
Automation updating the message in the catalog to the default value

Create a document with a catalog


In the final step of this process, you will create a document with the catalog created earlier in order to be able to return the catalog content to the mobile application. This will let you display information for the customer whether they can still use the promotion or not.

  1. Go to Data Management icon Data Management > Documents > Add document.

  2. Enter the name for your document. A slug (the ID of the document) is filled in automatically.

  3. To select the type of schema, in the Type section, open the dropdown list. A schema defines the method of validating the data included in the document.

  4. Optionally, in the Description field, you can add a description of the document.

  5. In the Content (JSON) section, paste the JSON code:

    {
    "copy": "{% set key = 'copyKey' %}{% catalog.UC-limited-promotion(key).copy %}"
    }
        

    Note: The above code contains the JSON object that will be returned to your mobile app. It contains one field (copy) with the value of message that should be displayed to the customer. This value is retreived using the Jinjava insert that enables to extract values form catalogs. You can use the code in your implementation but change the name of the catalog to the one you have created, as well as the names of the columns within it.
  6. Click Apply to save the document.

The view of the document configuration
Configuration of the document

What’s next


For this business scenario and automation to work, creating a document with a catalog is crucial. The mobile application will be able to retrieve the document with the current copy content, with the download document method (Android, iOS, React Native). Then, a JSON file with the raw content will be returned, which the app must properly display to the customer.

Check the use case set up on the Synerise Demo workspace


You can check the:

configurations directly in the 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