Introduction
Advanced partner setups sometimes require the tracking of visitors and number replacements to be initiated server-side. By using the Dynamic Numbers API, partners can programmatically simulate the requests that normally come through the Kaisa JavaScript.
Overview
When a client takes an action such as clicking "call now"-button, you have to invoke this Kaisa service server-side and pass the result back to the client. For complete user journey tracking, please contact Helpdesk.
The Dynamic Numbers API is exposed as a simple web service using JSON request and response data. A JSON request object containing the necessary parameters is sent to Kaisa service using HTTP POST. A JSON response object is returned containing the response data. A signature of the request data must be calculated and sent along with the request.
Kaisa service will normally process requests within 50 ms (excluding the network round trip), but we still suggest you to implement a timeout in case there is a temporary bad network connectivity and handle potential error responses by falling back to display or dial the original phone number. A suggested time out, including network round trips, is 1500 ms.
This service also supports requests from native apps.
Mandatory request parameters (web)
All mandatory parameters are sent in JSON body using HTTP POST:
{
"advId": "string","fullUrl": "string”,
"trackingId": "string",
"numbers": "string",
"type": "web",
"fullReferrer": "string",
"parameters":
{
"custnr": "string",
"custname": "string",
"custemail": "string",
"...": "string"
},
"userAgent": "string",
"requestIpAddress": "string",
"sessionId": "string"
}
Mandatory request parameters (app)
All mandatory parameters are sent in JSON body using HTTP POST:
{
"advId": "string",
"fullUrl": "string", // can be empty
"trackingId": "string",
"numbers": "string",
"type": "app",
"fullReferrer": "string",
"parameters":
{
"custnr": "string",
"custname": "string",
"custemail": "string",
"...": "string"
},
}
Validation rules for mandatory parameters:
- custnr: max 45 characters
- custname: max 60 characters
- custemail: max 150 characters
API parameters
A short explanation of the mandatory parameters used:
advId Account name with Kaisa
fullUrl The URL of the website where the Dynamic Number will be displayed
trackingId Partner generated visitor ID (for example, a logged in visitor)
numbers The phone number(s) to be replaced
fullReferrer The referrer URL of the visitor (if set)
parameters See custom dimensions below
userAgent The visitors user agent
requestIpAddress The IP address of the visitor (can be anonymised)
sessionId Kaisa generated session ID
Custom dimensions
Typically the parameters object will, at least, contain information to identify the end customer (Name, ID and Email). The parameters object can also contain N number of custom dimensions defined jointly by Kaisa and the partner.
Some examples of commonly used custom dimensions are:
- adId: the unique identifier for the ad
- adUrl: the base64 encoded URL of the ad
- adImage: the base64 encoded image URL of the ad
- adPrice: the price of the vehicle
- adKm: the mileage of the vehicle
- adBrand: the brand of the vehicle
These are then sent by the partner to Kaisa in order to identify the specific ad a visitor is calling for. Other fields can be added or configured after discussing this with the Support & Activation team, and the naming of the above examples can be configured as well.
Responses
Response data is given as JSON:
{
"success": "boolean",
"error": "string",
"numbers":
[{
"number_on_page": "string",
"replace_with":
{
"e164": "string",
"local": "string"
}
}],
"sessionId": "string"
}
Example of a successful response:
{
"success": true,
"numbers":
[{
"number_on_page": "+493015981100",
"replace_with":
{
"e164": "+493015981158",
"local": "030 15 98 11 58"
}
}],
"sessionId": "40846be9-88de-4120-bf8c-dfc2fd6c4c3"
}
Example of an error response:
{
"success": false,
"error": "Missing parameter: advId"
}
Response codes
The legacy default of this API is to return 200 OK for all response types, and the error is instead returned in the body of the response. If you want, you can override this and have the API return proper HTTP response codes, for example on errors. The full error is always sent back in the body of the response. To request proper response codes, please append the custom header X-HTTP-STATUSES to the request.
The response codes used are:
200 OK The request was successfully processed
400 Bad Request The request is missing information or contains bad information
403 Forbidden The request has not been processed, please see body for details
500 Internal Server Error The server failed to process the request, please see body
501 Not Implemented The server is missing configuration, please see body
Signature
The signature (HMAC) is calculated by using the full body data together with a secret key Kaisa will share with you. Currently the signature method used is SHA1. The calculated signature can be either appended to the end of the query string or sent as a custom header.
Consider the following simplified JSON object {“advid”:”123”,”numbers”:”321”} where the HMAC-SHA1 signature is calculated using the key kaisa
The signature can be passed either as a query parameter:
POST http://url/api?sign=bdc98a82e1d0c873ea95c35c2e7decbd3752a2fb
{“advid”:”123”,”numbers”:”321”}
or as a custom header:
POST http://url/api
X-SIGN: bdc98a82e1d0c873ea95c35c2e7decbd3752a2fb
{“advid”:”123”,”numbers”:”321”}
Comments
0 comments
Please sign in to leave a comment.