Create streaks

A streak refers to a consecutive series of actions or engagements by a customer, based on which loyalty benefits are provided.

You can create a streak using the Create target group API.

👍

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 .

Prerequisites

  • Authentication: Basic/OAuth authentication
  • Default access group

Resource information

URIv3/targetGroups
HTTP methodPOST
PaginationNA
Rate limitNA
Batch supportNA

API endpoint example

https://eucrm.cc.capillarytech.com/v3/targetGroups

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.
preferredTillIdNumberIdentifier for a preferred till.
trackingType*StringThe 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).
targetEvaluationTypeStringThe 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.
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.
periodStatusStringIndicates if the cycle of the Milestone is active/inactive.
refCodeStringA reference code for the period.
startDateDate TimeThe start date and time of the period.
targetsObjectAn array of target objects, each outlining a target within the tracking.
activeBooleanIndicates if the target is active.
descriptionStringA brief description of the target.
expressionStringA string representing the condition to meet the target.
expressionJsonStringA JSON expression that specifies the conditions required to achieve the target.
filtersObjectIn this object, you can define the entity to which the specified expressions related to the target will be applied.
entityTypeEnumThe entity to which the specified expressions related to the target will be applied.The entityType must satisfy the condition (expression) required to achieve the target.
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 or 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.
targetType*EnumThe type of target.
Supported values: QUANTITY, SALES, COUNT, VISIT, GROSS_SALES,
REGULAR_POINTS, PROMOTIONAL_POINTS,
ALL_POINTS, EXTENDED_FIELD and EVENT_ATTRIBUTE

The system supports targets based on behavioural events (SUM, VISIT, and COUNT). 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
For example: To track total cart value, use SUM as your "aggregateFunction" with a related behavioural event to sum up the value and check against your target.
defaultValuesObjectAn array of objects providing default values related to the target.
defaultValueIntegerA default value used in the target evaluation.
streaks*Object An array of streak information. If trackingType is Streaks, then name of streak and targetCountOfSequence are mandatory.
name*StringName of the streak.
targetCountOfSequence*IntegerThe number of times the user has to achieve the target to redeem the reward.
{
    "active": true,
    "description": "streak group",
    "name": "streakTestt123",
    "preferredTillId": 0,
    "trackingType": "STREAKS",
    "targetEvaluationType": "FIXED_CALENDAR_WINDOW",
    "totalPeriods": 1,
    "frequencyType": "CUSTOM",
    "periods": [
        {
            "active": true,
            "description": "p1",
            "endDate": "2023-11-17T23:45:12.063",
            "periodStatus": "RUNNING",
            "refCode": "period44",
            "startDate": "2023-11-17T00:45:12.063"
        },
        {
            "active": true,
            "description": "p1",
            "endDate": "2023-11-20T23:45:12.063",
            "periodStatus": "RUNNING",
            "refCode": "period45",
            "startDate": "2023-11-18T00:45:12.063"
        }
    ],
    "targets": [
        {
            "active": true,
            "description": "streak",
            "expression": "currentTxn.value>500",
            "expressionJson": "{\"arity\":\"binary_operation\",\"value\":\">\",\"type\":\"boolean:primitive\",\"operands\":[{\"arity\":\"object_dereference\",\"type\":\"real:object:primitive\",\"operands\":[{\"arity\":\"name\",\"value\":\"currentTxn\",\"type\":\"tx:object:primitive\"},{\"arity\":\"name\",\"value\":\"value\",\"type\":\"real:object:primitive\"}]},{\"arity\":\"literal\",\"value\":\"500\",\"type\":\"number:primitive\"}]}",
            "filters": [
                {
                    "entityType": "STORE",
                    "entityIds": [
                        50679757,
                        50679770
                    ]
                }
            ],
            "name": "streakTestt123",
            "targetEntity": "TRANSACTION",
            "enrolmentMethod": "TRANSACTION",
            "targetType": "SALES",
            "defaultValues": [
                {
                    "defaultValue": 500
                },
                {
                    "defaultValue": 1000
                }
            ]
        }
    ],
    "streaks": [
        {
            "name": "streakTestt193",
            "targetCountOfSequence": 1
        },
         {
            "name": "streakTestt123",
            "targetCountOfSequence": 2
        }
    ]
}

Response parameters

FieldDatatypeDescription
idintegerUnique identifier for the group.
namestringName of the group.
activebooleanIndicates if the group is active.
preferredTillIdintegerPreferred till ID, indicating no specific preference with 0.
totalPeriodsintegerTotal number of periods specified.
descriptionstringDescription of the /roup.
targetEvaluationTypestringType of target evaluation, e.g., "FIXED_CALENDAR_WINDOW".
targetCycleStartDatestring (date-time)Start date and time for the target cycle.
targetCycleEndDatestring (date-time)End date and time for the target cycle (if applicable).
frequencyTypestringFrequency type, e.g., "CUSTOM" (if applicable).
trackingTypestringType of tracking, e.g., "STREAKS" (if applicable).
fromDatestring (date)Start date for the setting (if applicable).
toDatestring (date)End date for the setting (if applicable).
recurringCyclesintegerNumber of recurring cycles specified (if applicable).
frequencyintegerFrequency value set for the setting (if applicable).
idintegerUnique identifier for each period.
startDatestring (date)Start date for each period.
endDatestring (date)End date for each period.
refCodestringReference code for each period.
periodStatusstringStatus of each period, e.g., "RUNNING", "NOT_STARTED".
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.
targetTypestringType of each target, e.g., "SALES".
targetEntitystringType of entity targeted by each target, e.g.
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.
entityTypestringType of entity for the filter of each target.
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": 9919,
        "name": "streakTestt123",
        "active": true,
        "preferredTillId": 0,
        "periods": [
            {
                "id": 10678,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "startDate": "2023-11-17",
                "endDate": "2023-11-17",
                "refCode": "period44",
                "periodStatus": "RUNNING",
                "targetGroupId": 9919,
                "description": "p1",
                "active": true
            },
            {
                "id": 10679,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.000+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "startDate": "2023-11-18",
                "endDate": "2023-11-20",
                "refCode": "period45",
                "periodStatus": "NOT_STARTED",
                "targetGroupId": 9919,
                "description": "p1",
                "active": true
            }
        ],
        "streaks": [
            {
                "id": 9,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "targetGroupId": 9919,
                "name": "streakTestt193",
                "targetCountOfSequence": 1
            },
            {
                "id": 10,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.483+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "targetGroupId": 9919,
                "name": "streakTestt123",
                "targetCountOfSequence": 2
            }
        ],
        "totalPeriods": 1,
        "description": "streak group",
        "targetEvaluationType": "FIXED_CALENDAR_WINDOW",
        "targetCycleStartDate": "2023-11-17T00:00:00.000Z",
        "targetCycleEndDate": "2023-11-20T23:59:59.000Z",
        "frequencyType": "CUSTOM",
        "trackingType": "STREAKS",
        "targets": [
            {
                "id": 22030,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.612+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.612+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "name": "streakTestt123",
                "emfRuleSetId": 1200627,
                "targetType": "SALES",
                "targetEntity": "TRANSACTION",
                "eventName": "TransactionAdd",
                "targetGroupId": 9919,
                "description": "streak",
                "active": true,
                "expression": "currentTxn.value>500",
                "expressionJson": "{\"arity\":\"binary_operation\",\"value\":\">\",\"type\":\"boolean:primitive\",\"operands\":[{\"arity\":\"object_dereference\",\"type\":\"real:object:primitive\",\"operands\":[{\"arity\":\"name\",\"value\":\"currentTxn\",\"type\":\"tx:object:primitive\"},{\"arity\":\"name\",\"value\":\"value\",\"type\":\"real:object:primitive\"}]},{\"arity\":\"literal\",\"value\":\"500\",\"type\":\"number:primitive\"}]}",
                "filters": [
                    {
                        "entityType": "STORE",
                        "entityIds": [
                            50679757,
                            50679770
                        ]
                    }
                ],
                "enrolmentMethod": "TRANSACTION",
                "defaultValues": [
                    {
                        "id": 24105,
                        "periodId": 10678,
                        "defaultValue": 500.000
                    },
                    {
                        "id": 24106,
                        "periodId": 10679,
                        "defaultValue": 1000.000
                    }
                ]
            },
            {
                "id": 22031,
                "attribution": {
                    "createdOn": "2023-11-17T07:04:44.789+0000",
                    "lastUpdatedOn": "2023-11-17T07:04:44.789+0000",
                    "lastUpdatedBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    },
                    "createdBy": {
                        "id": 50129465,
                        "code": "till_store1",
                        "description": "",
                        "name": "till_store1",
                        "type": "TILL"
                    }
                },
                "name": "streakTestt123_ReturnBill",
                "emfRuleSetId": 1200628,
                "targetType": "SALES",
                "targetEntity": "TRANSACTION",
                "eventName": "ReturnBill",
                "targetGroupId": 9919,
                "description": "streak",
                "active": true,
                "expression": "currentTxn.value>500",
                "expressionJson": "{\"arity\":\"binary_operation\",\"value\":\">\",\"type\":\"boolean:primitive\",\"operands\":[{\"arity\":\"object_dereference\",\"type\":\"real:object:primitive\",\"operands\":[{\"arity\":\"name\",\"value\":\"currentTxn\",\"type\":\"tx:object:primitive\"},{\"arity\":\"name\",\"value\":\"value\",\"type\":\"real:object:primitive\"}]},{\"arity\":\"literal\",\"value\":\"500\",\"type\":\"number:primitive\"}]}",
                "filters": [
                    {
                        "entityType": "STORE",
                        "entityIds": [
                            50679757,
                            50679770
                        ]
                    }
                ],
                "enrolmentMethod": "TRANSACTION",
                "defaultValues": [
                    {
                        "id": 24107,
                        "periodId": 10678,
                        "defaultValue": 500.000
                    },
                    {
                        "id": 24108,
                        "periodId": 10679,
                        "defaultValue": 1000.000
                    }
                ]
            }
        ]
    },
    "errors": null,
    "warnings": null
}
Language
Authorization
Basic
base64
:
URL
Click Try It! to start a request and see the response here!