The onsite API is used to interact with Commanders Act features with JavaScript.
The onsite API consists of a single function, cact()
, with the following strict signature:
Onsite API is included in each containers and privacy banners.
To send event data to the serverside Commanders Act platform, use this command:
Example : to send a purchase event :
To get various values from Commanders Act, use this command:
Example : to get consent from TrustCommander, you can call the consent.get
API like this:
The onsite API methods are called asynchronously. In case e.g. you need information synchronous in the <head>
of the document it is recommended to cache and retrieve the result of the API in localStorage
.
You can handle errors through error property in the callback object. Example:
For advance usage, we provide also an API stub that can be added when you need to interact with the API before containers or banners have loaded. This stub is already included in containers and privacy banners, so you do not have to add in most use cases. The stub is used to buffer all methods in a JavaScript array until Commanders Act JavaScript is loaded and ready to process the methods. This allows for example to use the onsite API before TrustCommander JavaScript was loaded.
window.caReady
is a JavaScript array that buffers the interactions with the API. window.cact
is a JavaScript function used to interact with the onsite API.
In case you work in a big team and are unsure the stub was already installed it is ok to install the JavaScript stub multiple times.
Returns the tags list
GET api.commander1.com/api/1.0/manage/container/tags/list?id_site=X&access_token=Y&id_container=Z
The response is in JSON format.
GET
Get platform users.
GET
https://api.commander1.com/v2/{siteId}/users
Two usages : GET /users/ : Returns a list of user properties (depending on the parameters requested) linked to the users of a site. GET /users/123 : Return properties of one user (id 123) on one site. Click below to download complete API documentation
Name | Type | Description |
---|---|---|
Argument
Descriptions
Required
command
A string identifier used to select the desired method.
Required
options
A JavaScript object that includes data passed to the method.
Optional
callback
A JavaScript callback function that is used to receive information or events from the onsite API.
Optional
URL PARAMETER
TYPE
MANDATORY
DESCRIPTION
id_site
Integer
Yes
Client site identifier
access_token
Alphanum
Yes
Caller’s security identifier
id_container
Integer
No
Container identifier
HTTP CODE
MESSAGE
DESCRIPTION
200
OK
The request went through, the result is in the answer’s body
400
Bad Request
The parameters are not ok or mandatory parameters are missing
401
Unauthorized
The security token does not match the site_id or the container_id
404
Not Found
A container identifier for the site_id parameter was not found
500
Internal Server Error
Internal server error
FIELD
TYPE
ALWAYS PRESENT ?
DESCRIPTION
idSite
Integer
Yes
Site identifier
containers
Array
Yes
Array containing the container list and their label
containers/id
Integer
Yes
Container identifier
containers/label
String
Yes
Container label
containers/is_active
Boolean
Yes
Container status (active=true, deleted=false)
tags
Array
Yes
Array containing the tag list and container label
tags/id
Integer
No
Tag identifier
tags/label
String
No
Tag label
id
integer
The user id
include
string
permissions
or roles
or both separated by a comma