Tracking traffic
Creating trackers
You can already navigate to the shop created in the previous section using its unique identified: https://api.eventix.io/:GUID
. As mentioned during the introduction of this section, this link is suboptimal in use. Therefore, you will create a tracker
resource in this section to deal with these issues. For this, you need the following information:
shop_id
: the GUID of the shop for which the tracker will be.name
: the name for the tracker.type
: the type of tracker. This can be one of Website, Facebook, Twitter, Pinterest, LinkedIn, Instagram, Email or Other.
Use the required information to make a POST request to https://api.eventix.io/trackers
. See the following code blocks for examples of such requests and the expected response to the requests.
- PHP
- GO
- Node
- Shell
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_POSTFIELDS => [
"shop_id" => $shopGUID,
"name" => "Poster promotion",
"type" => "other"
],
CURLOPT_URL => "https://api.eventix.io/trackers"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
payloadBuf := new(bytes.Buffer)
json.NewEncoder(payloadBuf).Encode({
"shop_id": shopGUID,
"name": "Poster promotion",
"type": "other"
})
req, _ := http.NewRequest("PUT", "https://api.eventix.io/trackers", bytes.NewBuffer(body))
req.Header.Add("Authorization", "Bearer " + accessToken)
resp, _ := http.DefaultClient.Do(req)
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
const options = {
"method": "POST",
"headers": {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json"
},
"body": JSON.stringify({
"shop_id": shopGUID,
"name": "Poster promotion",
"type": "other"
})
};
fetch("https://api.eventix.io/trackers", options)
.then(response => response.json())
.then(response => console.log(response))
curl -X POST \
-H "Authorization: Bearer $accessToken" \
-F "shop_id=$shopGUID" \
-F "name=Poster promotion" \
-F "type=other" \
"https://api.eventix.io/trackers"
{
"name": "Poster promotion",
"type": "other",
"shop_id": "7d2bb3a8-739b-41c8-afe0-80b66f70943a",
"code": "fa8gt3bq",
"guid": "9c19be30-e2ce-45cb-8adf-c31392c31869",
"updated_at": "2023-10-02T13:26:12+02:00",
"created_at": "2023-10-02T13:26:12+02:00"
}
As you can see, the response contains a code
field. This is the slug of the link to the shop. You can therefore now also access the shop through https://shop.eventix.io/:code
.
Getting statistics
After you created a tracker
for a shop, you can retrieve some statistics regarding this tracker
. To achieve this, make a GET request to https://api.eventix.io/statistics/trackers
. See the following code blocks for examples of such requests and the expected response to the requests.
- PHP
- GO
- Node
- Shell
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_URL => "https://api.eventix.io/statistics/trackers"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
req, _ := http.NewRequest("PUT", "https://api.eventix.io/statistics/trackers", bytes.NewBuffer(body))
req.Header.Add("Authorization", "Bearer " + accessToken)
resp, _ := http.DefaultClient.Do(req)
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
const options = {
"method": "GET",
"headers": {
"Authorization": `Bearer ${accessToken}`
}
};
fetch("https://api.eventix.io/statistics/trackers", options)
.then(response => response.json())
.then(response => console.log(response))
curl -X GET \
-H "Authorization: Bearer $accessToken" \
"https://api.eventix.io/statistics/trackers"
{
"...": "...",
"aggregations": {
"trackers": {
"doc_count": 9,
"fa8gt3bq": {
"doc_count": 0,
"statistics": {
"doc_count": 0,
"revenue": {
"doc_count": 0,
"statistics": {
"value": 0
}
},
"devices": {
"doc_count": 0,
"statistics": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
}
},
"counts": {
"doc_count": 0,
"statistics": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
}
}
}
}
}
}
}
You can also make a GET request to https://api.eventix.io/statistics/trackers
to list all tracker
resources currently stored in the Eventix system. However, the response to this request is a bit harder to navigate.