Using Engine API to trigger metrics

Engine API is an alternative approach to using EventTrack to triggering metrics

Using Engine API to trigger metrics in a client side manner does not require Engine API to be enabled on your site - it is supported "out of the box" for this use case.

The following is an example:

var engineapimetricpostdata = {
"visits": [{
"Data": {
"113325": {
"Hits": 1
"113329": {
"Hits": 1
"cookies": {
"SSSC": "808.G6961058701578968086.1|4876.132187",

var xhr = new XMLHttpRequest();"POST", "", true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
xhr.setRequestHeader('Sec-Datadog', 'test123');
xhr.onloadend = function() {
if (xhr.status != 200) {
console.log(`Error ${xhr.status}: ${xhr.statusText}`);
} else {
console.log(`Done, got ${xhr.response.length} bytes`);

Note: Cookies do not need to be sent in the payload if they are already being sent in the browser. Cookie values sent in the payload will take precedence if there are also cookie being sent.

more information on Engine API