Track event
curl --request POST \
--url https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "<string>",
"type": "<unknown>",
"userId": "<string>",
"channel": "<unknown>",
"context": {
"ip": "<string>",
"userAgent": "<string>"
},
"properties": {},
"messageId": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track"
payload = {
"event": "<string>",
"type": "<unknown>",
"userId": "<string>",
"channel": "<unknown>",
"context": {
"ip": "<string>",
"userAgent": "<string>"
},
"properties": {},
"messageId": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
event: '<string>',
type: '<unknown>',
userId: '<string>',
channel: '<unknown>',
context: {ip: '<string>', userAgent: '<string>'},
properties: {},
messageId: '<string>',
timestamp: '2023-11-07T05:31:56Z',
sentAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'event' => '<string>',
'type' => '<unknown>',
'userId' => '<string>',
'channel' => '<unknown>',
'context' => [
'ip' => '<string>',
'userAgent' => '<string>'
],
'properties' => [
],
'messageId' => '<string>',
'timestamp' => '2023-11-07T05:31:56Z',
'sentAt' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track"
payload := strings.NewReader("{\n \"event\": \"<string>\",\n \"type\": \"<unknown>\",\n \"userId\": \"<string>\",\n \"channel\": \"<unknown>\",\n \"context\": {\n \"ip\": \"<string>\",\n \"userAgent\": \"<string>\"\n },\n \"properties\": {},\n \"messageId\": \"<string>\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"sentAt\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"event\": \"<string>\",\n \"type\": \"<unknown>\",\n \"userId\": \"<string>\",\n \"channel\": \"<unknown>\",\n \"context\": {\n \"ip\": \"<string>\",\n \"userAgent\": \"<string>\"\n },\n \"properties\": {},\n \"messageId\": \"<string>\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"sentAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"event\": \"<string>\",\n \"type\": \"<unknown>\",\n \"userId\": \"<string>\",\n \"channel\": \"<unknown>\",\n \"context\": {\n \"ip\": \"<string>\",\n \"userAgent\": \"<string>\"\n },\n \"properties\": {},\n \"messageId\": \"<string>\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"sentAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"success": true
}{
"message": "<string>",
"success": true,
"code": "<string>",
"error": {}
}{
"message": "<string>",
"success": false,
"code": "<string>"
}Analytics
Track event
Track event
POST
/
analytics
/
track
Track event
curl --request POST \
--url https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "<string>",
"type": "<unknown>",
"userId": "<string>",
"channel": "<unknown>",
"context": {
"ip": "<string>",
"userAgent": "<string>"
},
"properties": {},
"messageId": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track"
payload = {
"event": "<string>",
"type": "<unknown>",
"userId": "<string>",
"channel": "<unknown>",
"context": {
"ip": "<string>",
"userAgent": "<string>"
},
"properties": {},
"messageId": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
event: '<string>',
type: '<unknown>',
userId: '<string>',
channel: '<unknown>',
context: {ip: '<string>', userAgent: '<string>'},
properties: {},
messageId: '<string>',
timestamp: '2023-11-07T05:31:56Z',
sentAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'event' => '<string>',
'type' => '<unknown>',
'userId' => '<string>',
'channel' => '<unknown>',
'context' => [
'ip' => '<string>',
'userAgent' => '<string>'
],
'properties' => [
],
'messageId' => '<string>',
'timestamp' => '2023-11-07T05:31:56Z',
'sentAt' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track"
payload := strings.NewReader("{\n \"event\": \"<string>\",\n \"type\": \"<unknown>\",\n \"userId\": \"<string>\",\n \"channel\": \"<unknown>\",\n \"context\": {\n \"ip\": \"<string>\",\n \"userAgent\": \"<string>\"\n },\n \"properties\": {},\n \"messageId\": \"<string>\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"sentAt\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"event\": \"<string>\",\n \"type\": \"<unknown>\",\n \"userId\": \"<string>\",\n \"channel\": \"<unknown>\",\n \"context\": {\n \"ip\": \"<string>\",\n \"userAgent\": \"<string>\"\n },\n \"properties\": {},\n \"messageId\": \"<string>\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"sentAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.api.commercengine.io/api/v1/{store_id}/storefront/analytics/track")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"event\": \"<string>\",\n \"type\": \"<unknown>\",\n \"userId\": \"<string>\",\n \"channel\": \"<unknown>\",\n \"context\": {\n \"ip\": \"<string>\",\n \"userAgent\": \"<string>\"\n },\n \"properties\": {},\n \"messageId\": \"<string>\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"sentAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"success": true
}{
"message": "<string>",
"success": true,
"code": "<string>",
"error": {}
}{
"message": "<string>",
"success": false,
"code": "<string>"
}Authorizations
Access token
Body
application/json
Model for analytics event
event name
commercengine user id
Show child attributes
Show child attributes
properties of the event
unique hash string.
timestamp when event occured
time when event sent to server
Was this page helpful?
โI