Create target based on Behavioural event

This document provides information on creating a target based on behavioral events.

Behavioral events are a way using which brands track the behavioral properties of their customers. For example:

  1. Whether a user has updated the profile picture?
  2. Whether a user has provided the product review?
  3. Whether a user has walked 5000 steps?

Using the milestones, brands can track these behavioral events and reward their users. For example:

  1. Give 100 points to the user for updating the profile picture 2 times a month.
  2. Give a $1 coupon to the user for giving 3 product reviews in a quarter.
  3. Give a fitness badge to the user for walking 5000 steps in 2 days.

📘

Note

Unlike targets such as QUANTITY, SALES, GROSS_SALES, REGULAR_POINTS, PROMOTIONAL_POINTS,
ALL_POINTS, EXTENDED_FIELD, where the user has to make 3 API calls (target-group, period, and target) to create a single target, the behavioural type of targets can be created using a single call by placing the entire information in the single call itself. It means the definition of all the keys will be the same except for the following:

  1. targetEntity = "Event".
  2. eventName = "name of the behavioral event".
    1. This key will be present in the request body for the behavioural event type of targets.
  3. targetType = "COUNT"/"VISIT"/"EVENT_ATTRIBUTE". Only these 3 are supported.
    1. When the targetType is given as "EVENT_ATTRIBUTE", then:
      1. An "extendedFieldInfo object is applicable that contains 2 parameters:
        1. aggregateFunction: "SUM"
        2. name: Name of the attribute of the behavioral event on which SUM needs to happen.
        3. "targetEntity": "EVENT",
          "eventName": "removedFromCart",
          "targetType": "EVENT_ATTRIBUTE",
          "extendedFieldInfo": {
              "name": "cartId",
              "aggregateFunction": "SUM"}
          
          "targetEntity": "EVENT",
          "eventName": "removedFromCart",
          "targetType": "COUNT"/"VISIT",
          "extendedFieldInfo": {
              "name": "cartId",
              "aggregateFunction": "SUM"}
          

👍

Note

For detailed information about our APIs and for hands-on testing, refer documentation in API overview and step-by-step guide on making your first API call in Make your first API call .

API endpoint example

Using create target group: https://eucrm.cc.capillarytech.com/v3/targetGroups

Prerequisites

  • Authentication: Basic/OAuth authentication
  • Default access group

Resource information

URIv3/targetGroups
HTTP methodPOST
PaginationNA
Rate limitNA
Batch supportNA

Request body parameters

Parameter NameData TypeDescription
activeBooleanIndicates if the tracking is active or not.
descriptionStringA brief description of the target group.
name*StringThe name identifier for the target group.

The character limit for the name is 200 characters.
preferredTillIdNumberIdentifier for a preferred till.
trackingTypeEnumThe type of tracking the milestone is created for. Supported values:

- Default (single target tracking),
- Unified (tracking multiple targets as a unit),
- Streak (Tracking the achievement of a user across the cycles continuously),
- Capping (Tracking the number of points a user has got over a period, so that capping can be applied).
- Non continuous streak (Non-continuous streaks is a variation of streak, where the user is not required to perform specified activity continously).
targetEvaluationTypeEnumThe evaluation strategy for the targets. Supported values:
FIXED_CALENDAR_WINDOW - Each cycle runs for a defined period from the selected start date.
CYCLIC_WINDOW - Cycle starts after customer's 1st transaction post enrolment.
PERIOD_AGNOSTIC_WINDOW - The cycle continues until the user achieves the specified target.
totalPeriodsNumberThe total number of periods over which the tracking is evaluated.
frequencyTypeEnumThe frequency of each cycle in which the user has to achieve the target value.
Supported values: Monthly, Quarterly, Half-yearly, Yearly, Weekly, Daily, CUSTOM.
frequencyNumberThe frequency count, relevant to the frequencyType.
recurringCyclesNumberThe number of cycles for which the tracking recurs.
periodsObjectAn array of period objects, each containing details about the individual periods within the tracking.
activeBooleanIndicates if the period is active.
descriptionStringA brief description of the period.
endDateDate TimeThe end date and time of the period.
periodStatusEnumIndicates if the cycle of the Milestone is running or upcoming.
Supported values: RUNNING, UPCOMING, NOT_STARTED.
refCodeStringA reference code for the period.
startDateDate TimeThe start date and time of the period.
targetsObjectAn array of target objects.
activeBooleanIndicates if the target is active.
descriptionStringA brief description of the target.
expressionStringA string representing the condition to meet the target aka rule.
expressionJsonStringA JSON expression that specifies the conditions required to achieve the target.
defaultValuesObjectAn array of objects providing default values related to the target.
defaultValueStringThe default value for the target
filtersObjectIn this object, you can define the entity to which the specified expressions related to the target will be applied.
enrolmentMethodEnumThe method of enrolment for the target. Supported values: TRANSACTION, IMPORT
entityTypeEnumThe entity to which the specified expressions related to the target will be applied.
For example: The user has to make a purchase of shoes from ABC store.
Here, purchase of shoes is the expression and the entity is ABC store.
Supported values: STORE, ZONE, CONCEPT.
entityIdsArray The IDs of the entities to which the is filter applied on.
nameStringThe name identifier for the target.
targetEntityEnumThe KPI on which the target is tracked.
Supported values: TRANSACTION, LINEITEM, EVENT, REWARDS.
To track the transactional KPIs, use TRANSACTION and LINEITEM .
To track the Behavioural events & EMF events, use EVENT.
To track the tracking based on rewards such as points, use REWARDS.
eventNameStringThe behavioral name of the event that triggers the target. Only valid in the case of behavioral events & EMF events.
targetType*EnumThe type of target.
Supported values: SUM, VISIT, and COUNT (These are only 3 supported for behavioral event type of targets)

To use SUM, set the value as EVENT_ATTRIBUTE and then define the details in the extendedFieldInfo object.
extendedFieldInfoObjectIncludes the details of the event attribute that needs to be tracked.
This object is applicable only when targetType is SUM.
nameStringEvent on which the sum calculation is performed. For example, the number of adding to cart events.
aggregateFunctionEnumThe aggregate function checks whether the behavioral event is satisfied based on the sum.
Supported values: SUM
defaultValuesObjectAn array of objects providing default values related to the target.
defaultValueIntegerA default value used in the target evaluation.

Request body parameters (that are related to target)

ParameterData TypeDescription
activeBooleanIndicates if the target is active.
descriptionStringA brief description of the target.
expressionStringA string representing the condition to meet the target.
expressionJsonJSONA JSON expression that specifies the conditions required to achieve the target.
filtersArrayIn this object, you can define the entity to which the specified expressions related to the target will be applied.
- entityIdsArray The IDs of the entities to which the is filter applied on.
- entityTypeEnumThe entity to which the specified expressions related to the target will be applied.
For example: The user has to make a purchase of shoes from ABC store. Here, purchase of shoes is the expression and the entity is ABC store.
Supported values: STORE, ZONE, CONCEPT.
name*StringName assigned to the target.
targetEntityEnumThe KPI on which the target is tracked. Supported values: TRANSACTION, LINEITEM, EVENT, REWARDS.
To track the transactional KPIs, use TRANSACTION and LINEITEM .
To track the Behavioural events, use EVENT.
To track the tracking based on rewards such as points, use REWARDS.
enrolmentMethodEnumThe method of enrolment for the target. Supported values: TRANSACTION, IMPORT
targetGroupId*IntegerID of the target group.
targetType*StringThe type of target.
Supported values: SUM, VISIT, and COUNT. To use SUM, set the value as EVENT_ATTRIBUTE and then define the details in the extendedFieldInfo object.
defaultValuesArrayAn array of objects providing default values related to the target.
- targetNameStringName of the target.
- periodIdIntegerUnique identifier for the period.
- defaultValueIntegerA default value used in the target evaluation.
extendedFieldInfoObjectIncludes the details of the event attribute that needs to be tracked. This object is applicable only when targetType is SUM.
- nameStringEvent on which the sum calculation is performed. For example, the number of adding to cart events.
- aggregateFunctionStringThe aggregate function checks whether the behavioral event is satisfied based on the sum.
Supported values: SUM

{
    "active": true,
    "fromDate": "2024-02-19T00:00:00.529Z",
    "name": "GoodNightForNightly",
    "preferredTillId": 50692127,
    "toDate": "2024-05-31T08:41:00.529Z",
    "trackingType": "DEFAULT",
    "totalPeriods": 2,
    "frequency": 1,
    "recurringCycles": 1,
    "targetEvaluationType": "FIXED_CALENDAR_WINDOW",
    "targetCycleStartDate": "2024-02-19T00:31:00.529Z",
    "periods": [
        {
            "active": true,
            "description": "p66912",
            "endDate": "2024-02-22T23:45:12.063",
            "periodStatus": "RUNNING",
            "refCode": "period66921",
            "startDate": "2024-02-19T00:00:00.529Z"
        },
        {
            "active": true,
            "description": "p66222",
            "endDate": "2024-04-30T23:45:12.063",
            "periodStatus": "NOT_STARTED",
            "refCode": "period6628911",
            "startDate": "2024-04-01T23:45:12.063Z"
        }
    ],
    "targets": [
        {
            "targetEntity": "EVENT",
            "targetType": "VISIT",
            "eventName": "goodNight",
            "defaultValues": [
                {
                    "defaultValue": "2"
                },
                {
                    "defaultValue": "3"
                }
            ],
            "targetMilestoneTriggers": [],
            "expression": "true",
            "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
            "filters": [],
            "name": "goodNightTargetRule",
            "enrolmentMethod": "TRANSACTION"
        }
    ]
}
 {
    "active": true,
    "description": "generic fixed group1",
    "fromDate": "2024-02-19T02:00:00.063",
    "name": "genericFixedTest1",
    "preferredTillId": 50697469,
    "toDate": "2024-10-31T08:41:00.529Z",
    "trackingType": "DEFAULT",
    "totalPeriods": 1,
    "frequency": 0,
    "recurringCycles": 0,
    "periods": [
        {
            "active": true,
            "description": "p1",
            "endDate": "2024-10-31T08:41:00.529Z",
            "periodStatus": "RUNNING",
            "refCode": "period444f5",
            "startDate": "2024-02-19T02:00:00.063"
        }
    ],
    "targets": [
        {
            "active": true,
            "description": "string",
            "expression": "true",
            "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
            "filters": [],
            "defaultValues": [
                {
                    "defaultValue": 4.000
                }
            ],
            "name": "fixedTarget1",
            "targetEntity": "EVENT",
            "enrolmentMethod": "TRANSACTION",
            "targetType": "EVENT_ATTRIBUTE", 
            "eventName": "test",
            "extendedFieldInfo": {
                "name": "step",
                "aggregateFunction": "SUM"
            }
        }
    ]
}

Response parameters

FieldDatatypeDescription
idintegerUnique identifier for the tagrget group.
namestringName of the target group.
activebooleanIndicates if the group is active.
preferredTillIdintegerPreferred till ID.
totalPeriodsintegerTotal number of periods specified.
descriptionstringDescription of the target.
targetEvaluationTypeEnumThe evaluation strategy for the targets. Supported values:
FIXED_CALENDAR_WINDOW - Each cycle runs for a defined period from the selected start date.
CYCLIC_WINDOW - Cycle starts after customer's 1st transaction post enrolment.
PERIOD_AGNOSTIC_WINDOW - The cycle continues until the user achieves the specified target.
targetCycleStartDatestring (date-time)Start date and time for the target cycle.
targetCycleEndDatestring (date-time)End date and time for the target cycle.
frequencyTypeEnumThe frequency of each cycle in which the user has to achieve the target value. Supported values: Monthly, Quarterly, Half-yearly, Yearly, Weekly.
trackingTypeEnumThe type of tracking the milestone is created for. Supported values:

- Default (single target tracking),

- Unified (tracking multiple targets as a unit),
- Streak (Tracking the achievement of a user across the cycles continuously),
- Capping (Tracking the number of points a user has got over a period, so that capping can be applied).
- Non continuous streak (Non-continuous streaks is a variation of streak, where the user is not required to perform specified activity continously).
fromDatestring (date)Start date for the target.
toDatestring (date)End date for thetarget.
recurringCyclesintegerNumber of recurring cycles specified.
frequencyintegerFrequency value set for the setting.
idintegerUnique identifier for each period.
startDatestring (date)Start date for each period.
endDatestring (date)End date for each period.
refCodestringReference code for each period.
periodStatusEnum Status of each period. Supported values: RUNNING, NOT_STARTED, UPCOMING.
targetGroupIdintegerIdentifier linking each period to a target group.
descriptionstringDescription of each period.
activebooleanIndicates if each period is active.
idintegerUnique identifier for each streak.
namestringName of each streak.
targetCountOfSequenceintegerTarget count of sequence for each streak.
idintegerUnique identifier for each target.
namestringName of each target.
targetTypeEnumThe type of target.
Supported values: COUNT, VISIT, SUM
To use SUM, set the value as EVENT_ATTRIBUTE and then define the details in the extendedFieldInfo object.
targetEntityEnumThe KPI on which the target is tracked. Supported values: TRANSACTION, LINEITEM, EVENT, REWARDS.
To track the transactional KPIs, use TRANSACTION and LINEITEM .
To track the Behavioural events, use EVENT.
To track the tracking based on rewards such as points, use REWARDS.
eventNamestringName of the event associated with each target.
descriptionstringDescription of each target.
activebooleanIndicates if each target is active.
expressionstringExpression defining the criteria for each target.
expressionJsonstring (JSON)Target expression in JSON format for each target.
entityTypeEnumThe entity to which the specified expressions related to the target will be applied.
For example: The user has to make a purchase of shoes from ABC store. Here, purchase of shoes is the expression and the entity is ABC store.
Supported values: STORE, ZONE, CONCEPT.
entityIdsarray of integersIDs of entities for the filter of each target.
enrolmentMethodstringMethod of enrolment for each target.
defaultValuefloatSpecifies a default value for the target criteria for each target.
{
    "data": [
        {
            "id": 9067,
            "attribution": {
                "createdOn": "2023-09-25T11:42:35.850+0530",
                "lastUpdatedOn": "2023-09-25T11:42:35.850+0530",
                "lastUpdatedBy": {
                    "id": 50666468,
                    "code": "amanv2",
                    "description": "",
                    "name": "amanv2",
                    "type": "TILL"
                },
                "createdBy": {
                    "id": 50666468,
                    "code": "amanv2",
                    "description": "",
                    "name": "amanv2",
                    "type": "TILL"
                }
            },
            "name": "test_name",
            "emfRuleSetId": 1246657,
            "emfUnrolledRulesetId": 1246656,
            "targetType": "COUNT",
            "targetEntity": "EVENT",
            "targetGroupId": 5869,
            "description": "test210",
            "active": true,
            "expression": "true",
            "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
            "filters": [
                {
                    "entityType": "ZONE",
                    "entityIds": [
                        0
                    ]
                }
            ],
            "enrolmentMethod": "TRANSACTION",
            "defaultValues": [
                {
                    "id": 10083,
                    "periodId": 1,
                    "defaultValue": 20
                }
            ],
            
        }
    ],
    "errors": null,
    "warnings": null
}
{
    "data": [
        {
            "id": 9067,
            "attribution": {
                "createdOn": "2023-09-25T11:42:35.850+0530",
                "lastUpdatedOn": "2023-09-25T11:42:35.850+0530",
                "lastUpdatedBy": {
                    "id": 50666468,
                    "code": "amanv2",
                    "description": "",
                    "name": "amanv2",
                    "type": "TILL"
                },
                "createdBy": {
                    "id": 50666468,
                    "code": "amanv2",
                    "description": "",
                    "name": "amanv2",
                    "type": "TILL"
                }
            },
            "name": "test_name",
            "emfRuleSetId": 1246657,
            "emfUnrolledRulesetId": 1246656,
            "targetType": "EVENT_ATTRIBUTE",
            "targetEntity": "EVENT",
            "targetGroupId": 5869,
            "description": "test210",
            "active": true,
            "expression": "true",
            "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
            "filters": [
                {
                    "entityType": "ZONE",
                    "entityIds": [
                        0
                    ]
                }
            ],
            "enrolmentMethod": "TRANSACTION",
            "defaultValues": [
                {
                    "id": 10083,
                    "periodId": 1,
                    "defaultValue": 20
                }
            ],
            "extendedFieldInfo": {
                "name": "tax_amount",
                "aggregateFunction": "SUM"
            }
        }
    ],
    "errors": null,
    "warnings": null
}

API error codes

CodeDescription
310069Target group name already exists
300004Invalid input, check all values and ensure they are correct.
310008Length of Target rule name cannot exceed 200
Language
Credentials
Basic
base64
:
URL
Click Try It! to start a request and see the response here!