Custom Integration (Backend Side) Guide and Restful API
Beta
This integration method is in beta and not recommended for frontend use. Please check other integration methods.
This tutorial provides a very simple and quick introduction to the Dengage integration for custom applications by walking you through details of different events. Dengage has a RESTful API to feed important events like page/product information and visitor actions to the Dengage Engine.
Dengage uses different event types for different visitor actions. You can define following events by using Dengage RESTful API:
In order to use Dengage RESTful API, you must be make POST requests to your data center end point with event details at request body. Request body must be formed as a valid json array.
Dengage accounts have two important system variables used in integration: API KEY and Data Center. You can access these values from Integrations menu of Denage Panel:
To access Integrations menu of Dengage Panel, please login to your Dengage account and navigate to
Settings > Integrations
.
Request body should be a json array whose elements are Dengage events that will be described in the next sections, you can send multiple events with a single request.
Requests must be made to proper end point. Endpoint url format is like
Request Endpoint Format:
<DATA CENTER URL>/add/events/v1.json?apiKey=<APIKEY>
Data Center Url is account specific and you should use the end point shown at Integrations page under Account Settings.
Api Key is your account's unique key to send requests to Dengage RESTful Api, and you can learn your Api Key from Integrations page under Account Settings
Example Api Key:
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Proper request end point is changing data center url and api key with your account specific value.
Dengage Restful API is based on json, so headers should match content type and response type.
All request should have the following headers:
Request body should be a json array whose elements are Dengage events that will be described in this document.
An example request body will be in this format:
[
{
"name": "PAGE_VIEW",
"userId": "XXXXXXXXXXXXXXXXX",
"sessionId": "YYYYYYYYYYYYYYYY",
"device": "IOS",
"pageUrl": "http://www.exampleshop.com/",
"referrer": "http://www.google.com/",
"category": "Product Page",
"subCategory": "Men > Sports"
},
{
"name": "PRODUCT_VIEW",
"userId": "XXXXXXXXXXXXXXXXX",
"sessionId": "YYYYYYYYYYYYYYYY",
"device": "IOS",
"productId": "EXAMPLE_PRODUCT_1"
}
]
--
RESTful API returns different status codes to show you status of your request. Summary of status codes are given:
Dengage event requests returns a json object as reponse.
Example format of response body is given below:
{
"campaigns": [
[],
[]
],
"responses": [
[],
[]
],
"timestamp": 1501142345512
}
If request is taken successfully, but there is an error with the request, statusCode
variable shows the error. Example format of response body indicating an error is given below:
{
"timestamp": "",
"responses": [],
"statusCode": "NO_DOMAIN_APIKEY_MATCH"
}
Details of response errors are given in secotion API Errors
If your request body has a field statusCode
, then you have an error in your request. Details of errors are given in below table:
Each event has to have user and session id fields to uniquely identify the user using your store and current session through out the visit.
User and session ids can be generated by Dengage and new ids can be reached by making GET requests to following url:
<DATA CENTER URL>/get/key?count=<KEY COUNT TO GENERATE>
Data Center Url is account specific and you should use the end point shown at Integrations page under Account Settings.
You should ask for one key to just getting key for session id, and ask for two keys to get keys for both user id and session id.
Request Body is a simple array with number of keys you have asked for. Example request body is shown below for two key request:
["XXXXXXXXXXXXXXXXXXXXXXX","YYYYYYYYYYYYYYYYYYYY"]
Alternative approach is creating and using your own unique ids. These ids can be any string, but must be unique for each user and session.
Every event in Dengage shares common parameters and you can add these parameters to all events that will be defined later.
Details of common parameters for events are given below:
When a visitor views a page, this event should be sent.
Parameters can be sent with page view event is given below (you can also add common parameters):
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"PAGE_VIEW",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"category":"Home Page”,
"device":"IOS"
}
]
BODY
When a visitor views a product, this event should be sent.
If product is also inside a page, don't forget to send a page view event with category 'Product Page' and subCategory product's category too.
Parameters can be sent with product view event is given below (you can also add common parameters):
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"PRODUCT_VIEW",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"TABLET"
"productId":"EXAMPLE_PRODUCT_1”,
"title":"Example Product”,
"inStock":"true”,
"url":"https://www.exampleshop.com/example-product-1/”,
"image":"https://cdn.exampleshop.com/example-product-1.png,
"category":"Men>Sports>Shoes”,
"brand":"Example Brand,
"price":349.99,
"oldPrice":449.99,
"gender":"M",
"colors":["black","red","blue"],
"sizes":["small","medium","large"],
"labels":["new-comer","top-seller"],
"params":{
"field1":"value1",
"field2":"value2"
}
}
]
BODY
Dengage uses basket operations as intermediary step for measuring success of recommendations throughout the conversion funnel. Basket success rate is also reported by Trendify and Bannerify to show individual performance of products, categories, brands and banners.
Basket operations are similar to page view and product view. There are two possible steps in a basket operation these are: add product to basket, remove product from basket.
When a visitor adds a product to basket/cart, this event should be sent.
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"BASKET_OPERATIONS",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"IOS",
"step":"add",
"productId":"EXAMPLE_PRODUCT_1",
"price":349.99,
"currency":"EUR",
"quantity":2
}
]
BODY
When a visitor removes a product from basket/cart, this event should be sent.
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"BASKET_OPERATIONS",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"IOS",
"step":"remove",
"productId":"EXAMPLE_PRODUCT_1",
"quantity":1
}
]
BODY
Parameters can be sent with basket operations event is given below (you can also add common parameters):
Dengage uses checkout operations to measure success of recommendations throughout the conversion funnel. Checkout information and steps are also used in email & personalization campaigns. Campaign, Trendify, Bannerify and Sales reports are feed from checkout information. It is essential for both analyitcs and recommendation capabilities to function properly.
Dengage track four different steps of checkout operation:
View Basket is the first step of checkout funnel, and followed by Customer Information.
When a visitor views his/her basket/cart, this event should be sent with basket details.
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"CHECKOUT",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"ANDROID",
"step":"basket",
"totalPrice":999.99,
"currency":"EUR",
"cartUrl":"http://www.exampleshop.com/cart/cart-1234567890/"
"productList":[
{
"productId":"EXAMPLE_PRODUCT_1",
"price":349.99,
"currency":"EUR",
"quantity":2
},
{
"productId":"EXAMPLE_PRODUCT_2",
"price":249.99,
"currency":"EUR",
"quantity":1
}
]
}
]
BODY
Customer Information is the second step of checkout funnel, and preceeded by View Basket & followed by Payment Information.
When a visitor enters customer information as second step of checkout funnel, this event should be sent with basket details.
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"CHECKOUT",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"ANDROID",
"step":"customer",
"totalPrice":999.99,
"currency":"EUR",
"cartUrl":"http://www.exampleshop.com/cart/cart-1234567890/"
"productList":[
{
"productId":"EXAMPLE_PRODUCT_1",
"price":349.99,
"currency":"EUR",
"quantity":2
},
{
"productId":"EXAMPLE_PRODUCT_2",
"price":249.99,
"currency":"EUR",
"quantity":1
}
]
}
]
BODY
Please refer to View Basket Step of Checkout for basket products detail and use the same information throughout the purchase funnel by only changing step information.
Payment Information is the third step of checkout funnel, and preceeded by Payment Information & followed by Purchase/Success.
When a visitor enters payment information as third step of checkout funnel, this event should be sent with basket details.
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"CHECKOUT",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"ANDROID",
"step":"payment",
"totalPrice":999.99,
"currency":"EUR",
"cartUrl":"http://www.exampleshop.com/cart/cart-1234567890/"
"productList":[
{
"productId":"EXAMPLE_PRODUCT_1",
"price":349.99,
"currency":"EUR",
"quantity":2
},
{
"productId":"EXAMPLE_PRODUCT_2",
"price":249.99,
"currency":"EUR",
"quantity":1
}
]
}
]
BODY
Please refer to View Basket Step of Checkout for basket products detail and use the same information throughout the purchase funnel by only changing step information.
Purchase/Success is the fourth and final step of checkout funnel, and preceeded by Payment Information.
When a visitor finalizes a purchase, this event should be sent with basket details.
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"CHECKOUT",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"ANDROID",
"step":"purchase",
"totalPrice":999.99,
"currency":"EUR",
"productList":[
{
"productId":"EXAMPLE_PRODUCT_1",
"price":349.99,
"currency":"EUR",
"quantity":2
},
{
"productId":"EXAMPLE_PRODUCT_2",
"price":249.99,
"currency":"EUR",
"quantity":1
}
]
}
]
BODY
Please refer to View Basket Step of Checkout for basket products detail and use the same information throughout the purchase funnel by only changing step information.
Detailed explanation for each parameter is given below:
Each product inside the basket can be defined with following parameters. See Checkout Parameters for defining checkout operation in which basket product is also defined.
Dengage tracks important user operations like sign-up/register, sign-in/login, sign-out/logout and also you can share your customer's information with Dengage by sending an update event.
There are 4 possible user/visitor operations:
When a visitor registers (sign-up) to your website, you should send a new user event.
If you want to share details of an already registered user with Dengage, please use User Update.
Details of parameters of new user is given below:
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"USER_OPERATIONS",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"MOBILE",
"step":"signup",
"username":"CUSTOMER USERNAME",
"fullName":"NAME SURNAME",
"email":"EMAIL OF THE CUSTOMER",
"phone":"MOBILE PHONE OF THE CUSTOMER",
"gender":"GENDER OF THE CUSTOMER",
"age":18,
"memberSince":"23.01.2014",
"location":"LOCATION OF THE CUSTOMER",
"segments":["segment1","segment2"],
"custom":{
"field1":"value1",
"field2":"value2"
}
}
]
BODY
When a registered customer logins (sign-in), a user login event should be sent to Dengage.
Details of parameters of user login is given below:
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"USER_OPERATIONS",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"MOBILE",
"step":"signin",
"username":"CUSTOMER USERNAME"
}
]
BODY
When a registered customer logouts (sign-out), a user logout event should be sent to Dengage.
Details of parameters of user logout is given below:
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"USER_OPERATIONS",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"MOBILE",
"step":"signout",
"username":"CUSTOMER USERNAME"
}
]
BODY
When you want to share an already registered customer information, provide details of the customer by sending an user update event. You can use both this integration for both frequently updating user information and instant updates when customer updates his/her personal information.
If you want to share a new registered user with Dengage, please use New User.
Details of parameters of user update is given below:
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"USER_OPERATIONS",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"MOBILE",
"step":"update",
"username":"CUSTOMER USERNAME",
"fullName":"NAME SURNAME",
"email":"EMAIL OF THE CUSTOMER",
"phone":"MOBILE PHONE OF THE CUSTOMER",
"gender":"GENDER OF THE CUSTOMER",
"age":18,
"memberSince":"23.01.2014",
"location":"LOCATION OF THE CUSTOMER",
"segments":["segment1","segment2"],
"custom":{
"field1":"value1",
"field2":"value2"
}
}
]
BODY
This integration enables any event & data important for you to be tracked by Dengage and become actionable. With this integration, you can send any non standard events & data to Dengage, and gives endless opportunities to track and take actions to your visitor's behaviour.
Details of parameters of custom event is given below:
An example curl request is given below:
curl \
--url 'https://dce1.segmentify.com/add/events/v1.json?apiKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
--request POST \
--header 'Origin: http://www.exampleshop.com' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-binary @- <<BODY
[
{
"name":"CUSTOM_EVENT",
"userId":"XXXXXXXXXXXXXXXXXXX",
"sessionId":"YYYYYYYYYYYYYYYYYYYYY",
"pageUrl":"http://www.exampleshop.com/",
"referrer":"",
"device":"MOBILE",
"type":"my_custom_event",
"params":{
"field1":"value1",
"field2":"value2"
}
}
]
BODY
This section will be available in next releases. To learn more about this integration, please contact with support team, by sending an email to support@segmentify.com.
This section will be available in next releases. To learn more about this integration, please contact with support team, by sending an email to support@segmentify.com.
This section will be available in next releases. To learn more about this integration, please contact with support team, by sending an email to support@segmentify.com.
This section will be available in next releases. To learn more about this integration, please contact with support team, by sending an email to support@segmentify.com.