Using Traces

Last updated:

The traces REST API provides a generic traceability mechanism regardless of the type of action or platform where it occurs. To accomplish this goal, it is channel-agnostic, meaning it does not rely on any platform-specific session identifiers (cookies, for example). Thus, each user is responsible for ensuring the persistence and association of such information.

For use cases where session identifiers are available (web browsers, for example), Prisma Campaigns recommends using the existing native SDK.

What is a trace?

Customers engage with Prisma Campaigns in different sessions called visits or trails. A trace is a method to group those visits. The most frequent use case consists of a prospective client interacting several times with different sections of the website, mobile app, or another channel. Prisma Campaigns creates a new trace the first time a user launches the application, or when they close a previous one (perhaps because he/she has already converted to another promotion).

URL Method Data
/API/traces/trace POST EDN o JSON

The posted information is an EDN or JSON object with two fields (both optional):

data = {
   :app-token "D17C100F-0668-400A-AF91-967FE1A09A9E"
   :customer-id "5114932"
}
data = {
   "app-token": "D17C100F-0668-400A-AF91-967FE1A09A9E",
   "customer-id": "5114932"
}
Parameter Description
app-token Integrated identifier of the application making the request
customer-id ID of customer starting the trace

If the person interacting with the application is not known, the customer-id field can be empty. In that case, the system will create an anonymous client for that interaction. The response is also an EDN or JSON object with a trace identifier, which will be used during subsequent visits to keep it linked. In case the trace is generated with an anonymous client ID, the API will return it as part of the output.

response = {
   :trace-id "D17C100F-0668-400A-AF91-967FE1A09A9E"
   :customer-id "5114932"
}

The result is defined by one of the following HTTP status codes:

Code Description
200 The operation was completed successfully
500 The trace could not be created

Visits

Prisma Campaigns will generate a new trail whenever a user visits the web site, opens the mobile application or interacts with any other alternative channel:

URL Method trace-id Data
/api/traces/:trace-id/trail POST Trace ID to identify the current visit EDN or JSON

The posted information is an EDN or JSON object with three fields where two (platform and language) are optional:

data = {
    :language "en-US"
    :platform "Chrome Browser"
    :channel: "atm"
}
data = {
    "language": "en-US",
    "platform": "Chrome Browser",
    "channel": "atm"
}
Parameter Description
language Language of the client device (optional)
platform Platform used by the customer (optional)
channel Channel used

The response is also an EDN or JSON object that includes a trail ID:

response = {
 :trail-id "D17C100F-0668-400A-AF91-967FE1A09A9E"
}
response = {
 "trail-id": "D17C100F-0668-400A-AF91-967FE1A09A9E"
}

The result is defined by one of the following HTTP status codes:

Code Description
200 The operation was completed successfully
500 The trail could not be created

Activity

The following table lists the different activities that can be done during a visit:

Type Description
location Visit to a page or screen
action The user performs an action (for example, clicking on a button)
conversion User converted successfully
dismiss User indicates he/she is not interested
entry-point User starts conversion funnel
funnel-step User advances a step in the conversion funnel
event Events not generated by the user

The actual execution is carried out through an API action:

URL Method trail-id Data
/api/traces/trail/:trail-id/action POST Trail ID to which this action will be associated EDN or JSON
data = {
 :name "conversion"
 :type :trail-action/conversion
 :data [{:name "field1"
         :value "value1"}
        {:name "field2"
         :value "value2"}]
}
data = {
 "name": "conversion",
 "type": "conversion",
 "data": [{"name": "field1",
         "value": "value1"},
        {"name": "field2"
         "value": "value2"}]
}
Parameter Description
name Activity name (related to the action type)
type One of the activity types described above preceded with :trail-action/.
data Data associated with the corresponding action

The result is defined by one of the following HTTP status codes:

Code Description
200 The operation was completed successfully
500 The trace could not be created

Conversion and No interest

By using the action API, it is possible to indicate when a client converts or if he/she is not interested in a campaign. Each action has a corresponding type, and the only required parameter is tracking-token (obtained previously in the channel).

For EDN, the following information is sent along with the action:

Example 1 (conversion):

data = {
    :name "conversion"
    :type :trail-action/conversion
    :data [{:name "tracking-token"
          :value "value"}]
}

Example 2 (dismiss):

data = {
    :name "dismiss"
    :type :trail-action/dismiss
    :data [{:name "tracking-token"
         :value "value"}]
}

For JSON, the action type should not include the :trail-action/ preffix:

Example 1:

data = {
    "name": "conversion",
    "type": "conversion",
    "data": [{"name": "tracking-token", "value": "value"}]
}

Example 2:

data = {
    "name": "dismiss",
    "type": "dismiss",
    "data": [{"name": "tracking-token", "value": "value"}]
}

Important: Once conversion or dismiss are invoked on a trace, it cannot be used again and a new trace will be created for subsequent actions, visits or synchronizations. In case the same trace is used, it will result in an HTTP 400 response.