Renewable quest

Published June 15, 2023
Modules
Difficulty

There are several ways to make a loyalty program an engaging experience for users. One way is to include personalized and frequently updated content, along with special promotions and attractive rewards. Another method can include gamification, which we will explore more deeply in this use case.

In Synerise, you can create gamification scenarios based on various user actions collected within the profile history like transactions, consents, form submissions, watching videos, rating products, and more. However, scenarios based on transaction events are the most popular. These scenarios involve completing quests that lead to rewards such as promotions, free products, extra loyalty points, or access to premium content.

Cover photo
Cover photo for renewable quest use case

In this use case, we will guide you through the process of building a renewable quest. This quest allows customers to earn 1000 loyalty points by purchasing 10 products from a specific category within a set timeframe.

Prerequisites


  • Implement transaction events using SDK or API. Make sure that you implement category parameter in the transaction events and quantity of products.
  • Integrate mechanism for awarding loyalty points. Find more in the Loyalty programs basics use case.

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 steps:

  1. Create a quest.renewableComplete event
  2. Create the aggregate that returns the timestamp of the last finished quest
  3. Create the aggregate with the number of product purchased
  4. Create an expression with the number of products required to complete the quest
  5. Create an expression that returns the number of products purchased
  6. Create an expression checking the conditions for completing the quest
  7. Create a workflow which adds points to the customer’s account
  8. Create a document with all necessary data conected with this loyalty scenario

Create a quest.renewableComplete event


In this part of the process, create a quest.renewableComplete event, which will be later generated in the workflow when the customer completes the quest. In addition, this event must contain a parameter that contains the name of the completed quest to facilitate identification of the quest. In our case, we use the gameName parameter.

  1. Go to Data Management icon Data Management > Events > Add event.
  2. In the Name field, enter quest.renewableComplete.
    In the API and SDK, the name parameter is usually called action or action name.
  3. Optionally, define a human-friendly display name that will be shown in the Data Managament and Analytics modules.
  4. Optionally, in the Description field, enter the description of the event.
  5. Enable the Make this event available to anonymous profiles without JWT toggle.
  6. Click Apply.
  7. In the list of events, find the event you just created.
  8. On the right side of the screen, click Add property.
  9. In the Source parameter field, enter gameName.
  10. In the Property name field, enter a human-readable label for display in the Synerise platform.
  11. Optionally, in the Description field, you can add an explanation about the purpose of this parameter.
  12. In Property type and Link fields, leave the default string and -.
  13. To complete the process, click Save.

Create an aggregate that returns the timestamp of the last finished quest


In this step, we create an aggregate that provides the timestamp of the most recently completed quest. The timeframe for the quest begins on the day it starts and continues until the expected completion time.

  1. Go to Analytics icon Analytics > Aggregates > Create aggregate.
  2. As the aggregate type, select Profile.
  3. Enter the name of the aggregate as [UC] Timestamp of last finished quest.
  4. Click Analyze profiles by and select Last.
  5. From the Choose event dropdown, select the questRenewableComplete event, that you created in the previous step.
  6. As the event parameter, choose TIMESTAMP.
  7. From the Choose parameter dropdown list, select the gameName parameter.
  8. From the Choose operator dropdown list, select Equal.
  9. Enter the name of the quest. In our case, it’s Towel's quest.
  10. Set the period for the aggregate to Custom and specify the desired data range. In this scenario, we will select the following time range 02.06.2023 - 30.05.2024.
  11. To save the aggregate, click Save.
Configuration of the aggregate
Configuration of the aggregate

Create an aggregate that returns the number of products purchased from the defined product category


In this part of the process, create an aggregate that will calculate the number of products that were purchased from the Paper_towels category after the last quest was completed.

  1. Go to Analytics icon Analytics > Aggregates > Create aggregate.
  2. As the aggregate type, select Profile.
  3. Enter the name of the aggregate as [UC]Number of products purchased after last finished quest.
  4. Click Analyze profiles by and select Sum.
  5. From the Choose event dropdown, select the product.buy event.
  6. As the event parameter, choose $quantity.
  7. Click the + where button and from the Choose parameter dropdown menu, choose category parameter.
  8. From the Choose operator dropdown menu, select Equal.
  9. Type the name of the product category - Paper_towels.
  10. Click the + where button and from the Choose parameter dropdown menu, choose TIMESTAMP parameter.
  11. From the Choose operator dropdown menu, select More than number operator.
  12. Click the Analytics icon (Choose value icon).
  13. From the Choose value dropdown list, select the aggregate you created earlier in the process.
  14. Set the period for the aggregate to Lifetime.
  15. Save the aggregate.
Configuration of the aggregate
Configuration of the aggregate

Create an expression with the number of products required to complete the quest


In this step, create an expression that determines the number of products needed to complete the quest. Based on the assumptions of this use case, the assumed requirement for purchase is 10 units.

  1. Go to Analytics iconAnalytics > Expressions > New expression.
  2. Enter the name of the expression as [UC]Target amount.
  3. Leave the Expression option at default (Attribute).
  4. Click the Select button.
  5. Choose # Constant.
  6. Open the settings of Constant value by clicking 0.
  7. In the field below, type 10
  8. Click Save.
The graphic shows the expressions settings
Final configuration of the expression

Create an expression that returns the number of products purchased


In this part of the process, create an expression that returns the number of products purchased from the Paper_towels category. This expression uses the aggregate and expression created in the previous steps.

Explanation of the expression logic

The logic in the expression compares the number of products purchased after the last finished quest to the target amount, which is 10 units needed to complete the quest. There are two possible scenarios:

  • If the number of products purchased from the “Paper_towels” category is equal to or greater than the target (10), the expression will return 10, indicating that the quest has been successfully completed.
  • If the number of products purchased from the “Paper_towels” category is less than the target, the expression will return the actual number of products purchased.

If the number of products purchased in a single transaction exceeds the target of 10, the surplus is not carried over to the next quest.

  1. Go to Profiles icon Analytics > Expression > New expression.
  2. Enter the name of the expression as [UC]Products purchased
  3. Leave the Expression option at default (Attribute).
  4. Build the following formula of the expression:
    Final configuration of the expression
    Final configuration of the expression
  5. Save the expression.

Create an expression that determines the number of products required to complete the quest


In this step, create an expression that checks if the number of products bought is equal to or greater than the target amount, indicating whether the customer has met all the conditions to finish the quest.

Explanation of the expression logic

The expression will produce one of two results based on certain conditions:

  • If the number of products purchased from the “Paper_towels” category is 10 or greater, the expression will return true.
  • If the number of products purchased from the “Paper_towels” category is less than 10, the expression will return false.

  1. Go to Profiles icon Analytics > Expression > New expression.
  2. Enter the name of the expression as [UC]Comparing amount of products bought
  3. Leave the Expression option at default (Attribute).
  4. Build the following formula of the expression:
    Final configurationj of the expression
    Final configurationj of the expression
  5. Save the expression.

Create a workflow


In this part of the process, create a workflow to determine if the customer has successfully completed the quest. The condition that needs to be met is the purchase of 10 products from the “Paper_towels” category. If the condition is met, two events will be generated for the customer:

  • An event quest.renewableComplete will be generated to inform about the quest completion.
  • An event points.upcharge will be generated to assign 1000 loyalty points to the customer.
  1. Go to Automation icon Automation > Workflows > New workflow.
  2. Enter the name of the workflow as [UC]Renewable Quest.

Define the Profile Event node


The workflow will be triggered by the product.buy when customers will purchase any product from the Paper_towels category.

  1. As the first node of the workflow, add Profile Event.
    1. From the Choose event dropdown menu, choose the product.buy event,
    2. As the parameter, choose category,
    3. As the operator, choose Equal,
    4. As the value of the parameter, add Paper_towels,
  2. Confirm by clicking Apply.
The graphic shows profile filter settings
The configuration of the Profile Event node

Define the delay


We need to set up a short delay of 10 seconds to ensure that events have been calculated before proceeding to the next condition in the workflow.

  1. Add the Deley node,
    1. Enter the name of the delay as 10s,
    2. Set the Delay number as 10,
    3. In Unit section choose Second,
  2. Confirm by clicking Apply.
The Delay node configuration
The Delay node configuration

Define the Profile Filter node


In this part of the process, we will check if the customer has completed the quest. We will use the previously created expression that determines whether the customer has met all the conditions to finish the quest. If the quest has been completed, the next step in the workflow will generate the quest.renewableComplete event. Otherwise, the process ends.

  1. Add the Profile Filter node. In the node settings:
    1. Click Choose event and select expression created earlier in the process,
    2. From the operator drop-down, choose Is true (Boolean),
  2. Confirm by clicking Apply.
The Profile Filter node configuration
The Profile Filter node configuration

Define the Generate Event node


In this part of the process the quest.renewableComplete event is generated, which informs us about the completion of the quest.

  1. To the matched path, add the Generate Event node.
  2. In the configuration of the node:
    1. Enter the Event name. In our case, we are using quest.renewableComplete event.
      The Label field exists for backwards compatibility. If your integration does not require this parameter, skip it.

    2. In the Body section, use the following Jinjava and modify it to your needs:

              {
                  "gameName": "Towel's quest"
              }
              
  3. Confirm by clicking Apply.
An example of a generated quest.renewableComplete event
Configuration of the Generate Event node with a quest.renewableComplete event

Define the secound Generate Event node


In this part of the process, a points.upcharge event will be generated, assigning 1000 loyalty points to customers who have finished the quest.

  1. Add the Generate Event node. 2. In the configuration of the node:
    1. Enter the Event name. In our case, we are using points.upcharge event. The Label field exists for backwards compatibility. If your integration does not require this parameter, skip it.
    2. In the Body section, use the following Jinjava and modify it to your needs:
              {
                  "gameName": "Towel's quest",
                  "points": 1000
              }
              
  2. Confirm by clicking Apply.
The graphic shows generate event settings
Configuration of the points.upcharge event

Add the finishing node and set capping

  1. Add the End node.
  2. In the upper right corner, click Set Capping and define the limit of workflows a profile can start in a specific time range.
  3. In the upper right corner, click Save & Run.
Configuration of the workflow
Configuration of the workflow

Create a document


In the final step of this process, you will create a document that will display in a selected channel (for example, a mobile application) the results of the expressions you created before, showing your customers how far are they in their quest.

  1. Go to Data Management icon Data Management > Documents > Add document.
  2. Enter the name for your document.

To create a document, you have to set up three steps of settings: audience, configuration, and schedule.

Set up Audience


In the audience section, determine who will be the recipient of the document.

  1. Click Define,
  2. Select Everyone,
  3. Save by clicking Apply.
Audience configuration in Document settings
Audience configuration in Document settings

Set up the Configuration section


In the configuration section, determine the content of the document.

  1. In the Slug field, enter the slug of the document, we recommend using the following name convention: this-is-slug-name. In our example enter the name of the event as towels.

  2. In the Priority field, use a number to define the document priority. The order of documents is defined by the priority value (1 is the highest, 100 is the lowest). In our example it will be 1.

  3. From the Type dropdown list, select a document type. Document type defines how the document is validated by your mobile application. To create a new type, from the dropdown list, click Add type. In our example it will be StampCampaign.

  4. In the Body field, add the content of the promotion in the JSON format. Body content will depend on the scenario of loyalty program. In our case, we display the results of the expressions created in previous parts of the process, a description, image, and some more information about the conditions of completing quest.

        {
                "current_status": " {% expression %} 1c92f585-3342-4fbd-af05-93f53ebe5882 {% endexpression %} ",
                "description": "Buy 10 product from towels category and get 1000 loyalty points",
                "format": "stamps",
                "image": "https://ecommerce.pl/media/catalog/product/towels/1/image/9df78eab33525d08d6e5fb8d27136e95/94989/regina-wish-recznik-papierowy-bialy-2-rolki-reczniki-papierowe-artykuly-higieniczne_0.jpg",
                "name": "Towels",
                "prize": "1000",
                "prizeType": "points",
                "target": "{% expression %} 930673cb-28d2-4a81-9100-7306bdfcce86 {% endexpression %}",
                "visibility": "1"
        }
     
    In the current_status and target parameters, we are referring to the expressions created earlier in the process. The current_status expression returns the actual number of products bought by the client, while the target expression determines the number of products needed to complete the quest.

  5. Save by clicking Apply.

Document settings configuration
Document settings configuration

Set up Schedule

In the schedule section, set the document activation date.

  1. Define the period as Run Imediately
  2. Save by clicking Apply.
The configuration of document schedule
The configuration of document schedule

To activate immediately or at a scheduled date, click the Activate button.

The graphic shows document settings
The graphic shows document settings

What’s next


For a screen view to be visible in a mobile application, you must fetch it using the appropriate SDK method for:

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.

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