Using Campaign APIs

Last updated:

Prisma Campaigns provides several campaign-related APIs. The endpoints listed below allow developers to retrieve active campaigns for each client, show the banners and images in placeholders, view funnel steps, and even trigger campaigns based on business events.

Active campaigns

This API returns all the active campaigns of a given client. To use it, do the following:

URL Method Data
/api/campaigns/active POST EDN

The posted information format is an EDN object:

data = {
   :app-token "D17C100F-0668-400A-AF91-967FE1A09A9E"
   :customer-id "5114932"
   :category "Sales"
   :group "Cars"
   :trail-id  "882252f3-fe70-4402-9195-639d8037f339"
}
Parameter Description
app-token Integrated identifier of the application making the request
customer-id Customer ID (if available)
category (Optional) Name of a campaign category to use as filter
group (Optional) Name of a campaign group to use as filter
trail-id Trail ID to which this action will be associated

Banners and popups

With this API, you can return the list of banners and images available in a given placeholder. Each page or screen can potentially include several banners (or at least a single popup). In any event, you will synchronize the app screen by invoking a single API. The response includes all the elements corresponding to that screen for the customer in question.

URL Method Data
/api/campaigns/sync-page POST EDN or JSON
data = {
    :app-token "D17C100F-0668-400A-AF91-967FE1A09A9E"
    :customer-id "5114932"
    :trail-id "882252f3-fe70-4402-9195-639d8037f339"
    :sync-popups true
    :page-location "http://my.domain/page"
    :placeholders [
        {:placeholder "id-placeholder1"}
        {:placeholder "id-placeholder2"}
    ]
}
"data": {
    "app-token": "D17C100F-0668-400A-AF91-967FE1A09A9E",
    "customer-id": "5114932",
    "trail-id": "882252f3-fe70-4402-9195-639d8037f339",
    "sync-popups": "true",
    "page-location": "http://my.domain/page",
    "placeholders": [
        {"placeholder": "id-placeholder1"},
        {"placeholder": "id-placeholder2"}
    ]
}
Parameter Description
app-token Integrated identifier of the application making the request
customer-id Customer ID (if available)
placeholders List of defined placeholders in the page or screen of interest
trail-id Trail ID to which this action will be associated
page-location ID of screen or page
sync-popups Boolean flag to indicate whether to recover popups from the current page-location or not

The response is an EDN or JSON object with two sets of information:

  1. Banners to display in each placeholder
  2. Information about the popup to display (if applicable)

and has the following structure:

response = {
   :popup = {}
   :placeholders = [{} {}]
}
"response": {
   "popup": {},
   "placeholders": [{}, {}]
}

The information structure of a popup contains the following data:

popup = {
    :tracking-token
    :campaign
    :show-close
    :funnel
}
Response Description
tracking-token Interaction ID (for traceability purposes)
campaign Campaign ID
show-close Boolean flag to indicate whether to allow the client to close the popup window or not
funnel Funnel configuration parameters

In order to display the funnel associated with this popup, you should use the API as follows: /api/campaigns/:campaign/funnel?d=:tracking-token&a=:app-token&t=:trail-id&popup=true

Placeholders

The placeholders attribute in the sync-page API response contains the list of banners to be displayed in each of the requested placeholders.

If a placeholder does not have any banners associated with it for a given client, the response will be empty.

The structure of the response for each placeholder is shown below:

placeholder = {
    :customer-id "5114932"
    :banners-list [{b1} {b2}]
    :is-popup false
    :popup-timeout 1000
    :transition-time 5000
    :width 800
    :height 600
}
Parameter Description
customer-id Customer ID or a temporary identifier in the case of an anonymous client
banners-list List of banners associated to a placeholder
transition-time Transition time between images if placeholder is in carousel mode
is-popup Boolean flag to indicate whether a banner will be shown in the popup (according to its configuration)
popup-timeout Timeout to close popup if it is displaying a banner

Each object inside banners-list contains the details of a banner for that placeholder. In case there are more than one, it will be possible to display them in different formats (carousel mode, grid, etc).

banner-detail = {
    :banner {banner object}
    :funnel {funnel object}
}
Parameter Description
width Placeholder width
height Placeholder height
campaign Campaign ID
tracking-token Interaction ID (for traceability purposes)
Link (Optional) Image link in case it is an image banner
HTML-content (Optional) HTML content in case banner consists of HTML code

Within the funnel object, there are properties related to the customer’s conversion process along with the data regarding the first funnel step.

Parameter Description
style Particular styles to apply to the funnel (in CSS format)
allow-dismiss Boolean flag that indicates if this campaign allows the user to dismiss it
landing-page Boolean flag that reveals if the campaign has a defined landing page
always-use-landing Boolean flag that denotes if the screen must always display the landing page initially
show-progress-bar Boolean flag that specifies if the funnel progress bar should be displayed or not
new-window Boolean flag that indicates if the funnel should be displayed in a new window

Funnel steps

To obtain the steps defined for the funnel, you can use the advance-funnel API, which will return the steps (one by one) as the customer completes them.

If there are forks in the funnel, based on the data or other user parameters, the next step will be determined after the current action concludes. Thus, you must use the API to obtain the first funnel step when the customer becomes interested in the campaign, as well as the following steps as each one finishes.

URL Method Data
/api/campaigns/advance-funnel POST EDN or JSON

The posted information format is an EDN or JSON object:

data = {
 :trail-id  "882252f3-fe70-4402-9195-639d8037f339"
 :campaign-id 123123101
 :tracking-token "12312-21919-j1b3-121m-1212"
 :step-data {}
}
"data": {
 "trail-id": "882252f3-fe70-4402-9195-639d8037f339",
 "campaign-id": "123123101",
 "tracking-token": "12312-21919-j1b3-121m-1212",
 "step-data": {}
}
Parameter Description
trail-id Trail ID to which this action will be associated
campaign-id Campaign ID
tracking-token Interaction ID (for traceability purposes)
step-data Information about previous funnel step(s), if any

The campaign-id and tracking-token parameters must match the interaction the user made. For example, if the user clicked on a banner, the campaign and tracking-token data corresponding to that banner should be included.

The step-data parameter should not be sent when the user starts the funnel. In all other cases, it is required (even if empty) to move to the next step.

The structure of the response is shown below:

response = {
  :type data-capture | message | redirect
  :config {}
}
Response Description
type Step type (data-capture, message, or redirect)
config Step settings (based on type)

The configuration detail for each step type is described below.

Message Step

step = {
 :title
 :message
 :actions
 :remaining-steps
 :max-steps
}
"step": {
 "title":
 "message":
 "actions":
 "remaining-steps":
 "max-steps":
}
Data Description
title Message title
message Message to display
actions List of actions available in the step: next, cancel, etc.
remaining-steps Number of remaining funnel steps
max-steps Maximum number of funnel steps

Data capture

step = {
 :fields
 :actions
 :remaining-steps
 :max-steps
}
"step": {
 "fields":
 "actions":
 "remaining-steps":
 "max-steps":
}

where

Data Description
fields List of fields to capture
actions List of actions available in the step: next, cancel, etc.
remaining-steps Number of remaining funnel steps
max-steps Maximum number of funnel steps

The fields list indicates which fields the customer should fill out in this step, where each follows this structure:

field = {
  :label
  :name
  :control-type
  :value
}
"field": {
  "label":
  "name":
  "control-type":
  "value":
}
Data Description
label Label to display in the capture field
name Field name
control-type Type of control to use for the data capture
value Current value of the field, if any

When you invoke the advance-funnel API, the step data must contain the values of the captured fields using name as a reference.

Redirect

The configuration detail for redirect steps is the following:

step = {
   :url
   :method
   :parameters
   :include-system-params
   :new-window
}
"step": {
   "url":
   "method":
   "parameters":
   "include-system-params":
   "new-window":
}
Data Description
url Redirect URL
method GET or POST, based on the redirection type
parameters List of parameters for the query string
include-system-params Boolean flag that indicates if campaign-id, trail-id and tracking-token are required in the query string
new-window Boolean flag that indicates if redirection should be performed in a new window

Customers

This endpoint allows you to create or update the information of a new or existing customer:

URL Method Data
/api/customers POST EDN or JSON

The format of the posted information is an EDN or JSON object:

data = {
 :customer {:id 12345
            :field "xxyyzz"}
 :app-token "882252f3-fe70-4402-9195-639d8037f339"
}
"data": {
 "customer": {"id": "12345",
            "field": "xxyyzz"},
 "app-token": "882252f3-fe70-4402-9195-639d8037f339"
}
Parameter Description
app-token Integrated identifier of the application making the request. The REST platform must be selected in the application.
customer Customer to update, where id is mandatory. The rest of the fields that are sent must exist in the defined schema and match the data type.

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

Code Description
200 The operation was completed successfully
404 The application token is invalid
400 Errors in the type of data sent
500 The API call could not update the database

Business Events

Campaigns can be triggered based on certain business events that are particular for each company, and Prisma Campaigns provides a method to do so. Since business events only have meaning in the scope of an application, the administrator must configure the application that will potentially trigger them. To do this, go to Settings/Applications and create a new business event by entering a name (which must be unique) and a description.

Next, you can associate a business event with a campaign in the corresponding section of the campaign settings. By default, business events apply to all the customers in the segment, but you can also filter them if you need to.

To trigger a business event, send a POST request as follows:

url method data
/api/campaigns/business-event POST EDN or JSON

The body of the request must contain the following data:

Data Description
app-token Application token
event-name The name of the event, as defined in the application settings
customer-id The customer’s unique ID
context An object containing additional parameters

The server will return a 202 Accepted status in case of success or 404 Not Found if no matching campaign is found. Additionally, the response includes the following fields:

Data Description
campaign Name of the campaign that was triggered
trace-id Unique ID of the trace generated for the current funnel
tracking-token Generated tracking token

Note: The server may return an EDN or JSON object depending on the content of the Accept and Content-Type headers. It is worth noting that the latter is mandatory.