Create target based on EMF event

In this API documentation, information regarding "creating a target based on emf event (aka customer level events)" can be found.

EMF Events are nothing but the different kinds of customer-level events present in loyalty workflows. For example, returnTransaction, pointsRedemption, etc... and all these are different kinds of EMF events in our systems.

Important note:

Now, brands will be able to create targets based on these EMF events. Now, unlike the normal targets, where the user has to make 3 API calls (target-group, period, and target) to create a single target, the EMF 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 emf event".
    1. This is a new key that will be present in the request body for the behavioral event type of targets.
    2. As of today, we are only supporting the following:
      1. CustomerRegistration
      2. PointsRedemption
      3. ReturnBill
      4. PointsTransfer
  3. targetType = "COUNT""VISIT". Only these 2 are supported for the EMF event type of targets.

👍

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 (that are related to target-group)

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 (continuous achievement tracking)
- Capping (points tracking with capping)
- Non continuous streak (like streak but non-continuous).
targetEvaluationTypeEnumStrategy for evaluating targets. Supported values:
- FIXED_CALENDAR_WINDOW
- CYCLIC_WINDOW
- PERIOD_AGNOSTIC_WINDOW
totalPeriodsNumberThe total number of periods over which the tracking is evaluated.
frequencyTypeEnumFrequency of each cycle. 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.
periodsObjectArray of period objects with:
- active (Boolean)
- description (String)
- endDate (Date Time)
- periodStatus (Enum: RUNNING, UPCOMING, NOT_STARTED)
- refCode (String)
- startDate (Date Time)
targetsObjectArray of target objects with:
- active (Boolean)
- description (String)
- expression (String)
- expressionJson (String)
- filters (Object)
- entityType (Enum: STORE, ZONE, CONCEPT)
- entityIds (Array)
- name (String)
- targetEntity (Enum: TRANSACTION, LINEITEM, EVENT, REWARDS)
- eventName (String)
- targetType* (Enum: VISIT, COUNT [only supported for EMF event targets])
extendedFieldInfoObjectUsed when targetType = SUM. Includes:
- name (String): Event to sum on
- aggregateFunction (Enum: SUM)
Note: Not applicable to EMF event type targets.
defaultValuesObjectArray of default value objects:
- defaultValue (Integer)
expressionStringCondition (rule) to meet the target.
expressionJsonStringJSON expression for the condition to achieve the target.
filtersObjectDefines entity for applying expressions.
entityTypeEnumEntity type for the filters. Supported values:
STORE, ZONE, CONCEPT
Example: "Purchase shoes from ABC store" → ABC store is the entity.
entityIdsArrayEntity IDs to which the filter applies.
periodStatusEnumMilestone cycle status. Supported: RUNNING, UPCOMING, NOT_STARTED.
targetEntityEnumThe KPI being tracked. Supported values:
- TRANSACTION, LINEITEM (for transactional KPIs)
- EVENT (for behavioral/EMF events)
- REWARDS (for points-based tracking)
eventNameStringBehavioral event name that triggers the target (valid for behavioral/EMF events only).
targetType*EnumTarget type. Supported for EMF: VISIT, COUNT
defaultValueIntegerA default value used in target evaluation.
refCodeStringA reference code for the period.
startDateDate TimeStart date and time of the period.
endDateDate TimeEnd date and time of the period.

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.
    - entityIdsArrayThe 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: VISIT, and COUNT.
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. Not applicable here.
    - 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": "PointsRedemption",
            "defaultValues": [
                {
                    "defaultValue": "2"
                },
                {
                    "defaultValue": "3"
                }
            ],
            "targetMilestoneTriggers": [],
            "expression": "true",
            "expressionJson": "{\"arity\":\"literal\",\"value\":\"true\",\"type\":\"boolean:primitive\"}",
            "filters": [],
            "name": "goodNightTargetRule",
            "enrolmentMethod": "TRANSACTION"
        }
    ]
}

Response parameters (that are related to the target group)

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

Character limit: 200.
preferredTillIdNumberIdentifier for a preferred till.
trackingTypeStringType of tracking. Supported values:

- Default
- Unified
- Streak
- Capping
targetEvaluationTypeStringTarget evaluation strategy. Supported values:
- FIXED_CALENDAR_WINDOW
- CYCLIC_WINDOW
- PERIOD_AGNOSTIC_WINDOW
totalPeriodsNumberThe total number of periods over which the tracking is evaluated.
frequencyTypeEnumFrequency of each cycle. Supported: Monthly, Quarterly, Half-yearly, Yearly, Weekly.
frequencyNumberFrequency count relevant to the frequencyType.
recurringCyclesNumberNumber of cycles for recurring tracking.
periodsObject[]Array of period objects with:
- active, description, endDate, periodStatus, refCode, startDate.
targetsObject[]Array of target objects with:
- active, description, expression,expressionJson, filters,entityType, entityIds,name, targetEntity, eventName, targetType.
extendedFieldInfoObjectOnly for targetType = EVENT_ATTRIBUTE. Includes:
- name, aggregateFunction (SUM)
defaultValuesObject[]Default value objects:
- defaultValue* (Integer)
streaksObject[]Streak objects:
- name, targetCountOfSequence (Integer)

Response Body Parameter (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.
    - entityIdsArrayThe 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: VISIT, and COUNT.
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. Not applicable here.
    - 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

Response parameters (that are related to the target)

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.

Character limit: 200.
preferredTillIdNumberIdentifier for a preferred till.
trackingTypeEnumType of tracking:

- Default
- Unified
- Streak
- Capping
- Non continuous streak
targetEvaluationTypeEnumEvaluation strategy:
- FIXED_CALENDAR_WINDOW
- CYCLIC_WINDOW
- PERIOD_AGNOSTIC_WINDOW
totalPeriodsNumberTotal number of periods evaluated.
frequencyTypeEnumCycle frequency. Supported values: Monthly, Quarterly, Half-yearly, Yearly, Weekly, Daily, CUSTOM.
frequencyNumberFrequency count relative to frequencyType.
recurringCyclesNumberNumber of recurring cycles.
periodsObjectArray of period objects with:
- active, description, endDate, periodStatus, refCode, startDate
periodStatusEnumMilestone cycle status:
- RUNNING, UPCOMING, NOT_STARTED
targetsObjectArray of target objects with:
- active, description, expression, expressionJson, filters, entityType, entityIds, name, targetEntity, eventName, targetType*
targetType*EnumTarget type (only VISIT, COUNT supported for EMF event targets).
extendedFieldInfoObjectUsed if targetType = SUM (not for EMF targets). Includes:
- name, aggregateFunction (SUM)
defaultValuesObjectArray of objects with:
- defaultValue (Integer)
expressionStringRule condition to meet the target.
expressionJsonStringJSON expression specifying the rule.
filtersObjectEntity definition to which the rule applies.
entityTypeEnumEntity context: STORE, ZONE, CONCEPT
entityIdsArrayEntity IDs to apply the filter.
refCodeStringReference code for the period.
startDateDate TimeStart date and time of the period.
endDateDate TimeEnd date and time of the period.
eventNameStringEvent name that triggers the target (behavioral/EMF).
targetEntityEnumKPI tracked:
- TRANSACTION, LINEITEM, EVENT, REWARDS
defaultValueIntegerDefault value for target evaluation.

{
    "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": "VISIT",
            "targetEntity": "EVENT",
            "eventName":"PointsRedemption"
            "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
}

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!