Headless tracking API reference

Website personalisation: Headless API integration

Options and parameters for the tracking API reference.

POST "https://{{domainkey}}.store-{{locationkey}}.ometria.services/api/track"
{
    "request_id"    : {{ request_id }},     /* optional (String or Number) */
    "scope"         : {{ scope }},          /* required (String) */
    "action"        : {{ action }},         /* required (String) */
    "data"          : {{ data }},           /* required (String) */
    "user": {
        "uid"           : {{ uid }},            /* required (String) */
        "sid"           : {{ sid }}             /* required (String) */
    },
    "context": {
        "category"      : {{ category_id }},    /* optional (String) */
        "product"       : {{ product_id }},     /* optional (String) */
        "page"          : {{ page_id }},        /* optional (String) */
        "page_url"      : {{ page_url }},       /* optional (String) */
        "user_agent"    : {{ user_agent }},     /* optional (String) */
        "language"      : {{ language_id }},    /* optional (String) */
        "currency"      : {{ currency_id }},    /* optional (String) */
    }
}
ParameterRequired?TypeDescription
request_idOptionalString or numberA string or number containing a unique identifier.

The API will return this value back with the response.
scopeRequiredStringA string that defines the type of tracking event being recorded.

The allowed values are:

- view
- basket
- order
actionRequiredStringDefines the type of tracking event being recorded.

The allowed values are depend on the event:

- basket - add, remove
-order - add, cancel, return
dataRequiredObjectA object which contains information specific to the current event.

The allowed values are depend on the event:

- basket - product_id, quantity
- order - order_id, order_total, order_currency, order_lines.

See: Headless tracking API examples
contextOptionalObjectAn object containing key information about the current request.

The context object required for tracking is the same as for queries.

See the documentation on the Query API for the JavaScript integration.

Headless tracking API examples

Add to basket

Track an add to basket event:

POST "https://{{domainkey}}.store-{{locationkey}}.ometria.services/api/track"
{
   "scope"         : "basket",
   "action"        : "add",
   "data"          : { "product_id": "{{ product_id }}", "quantity": 1 },
   "user": {
       "uid"           : "ebf3175817b0423eac68a03c68a9be5f",
       "sid"           : "961c660991a547298af8b31f431a66b0"
   },
   "context": {
       "category"      : "accessories",
       "page_url"      : "https://mywebsite.com/accessories/",
       "user_agent"    : "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
   }
}

Order placed

Typically this would be placed on the order confirmation page.

The order line total is the cost of the item (after tax) x the quantity purchased.

For example, if a t-shirt cost $10.00 but the customer bought two, then the order_line_total would be $20.00.

POST "https://{{domainkey}}.store-{{locationkey}}.ometria.services/api/track"
{
   "scope"         : "order",
   "action"        : "add",
   "data"          : {
       "order_id"          : "ABC-123",
       "user_id"           : "65ff6947c5c84a1199c7a32d7ac17c48",
       "order_total"       : 74.96,
       "order_tax"         : 11.66,
       "order_shipping"    : 4.99,
       "order_currency"    : "USD",
       "order_lines": [
           {
               "product_id"        : "6560241647794",
               "product_sku"       : "blk-drss",
               "product_name"      : "Maxi Dress",
               "variant_id"        : "39380778287282",
               "variant_sku"       : "mxi-drs-red",
               "quantity"          : 1,
               "unit_rrp"          : 40.00, // if available (includes tax)
               "order_line_total"  : 49.99 // includes tax
           },
           {
               "product_id"        : "abc",
               "product_sku"       : "123",
               "product_name"      : "Rainbow Scarf",
               "variant_id"        : "xyz",
               "variant_sku"       : "321",
               "quantity"          : 2,
               "unit_rrp"          : 8.00, // if available (includes tax)
               "order_line_total"  : 19.98 // item price 9.99 (including tax) x quantity 2
           }
       ]
   }
}

Order cancelled

Notify Ometria of any cancelled orders.

In some cases it may not be possible to populate the context object since the request may be disconnected from the website.

POST "https://{{domainkey}}.store-{{locationkey}}.ometria.services/api/track"
{
   "scope"         : "order",
   "action"        : "cancel",
   "data"          : { "order_id": "{{ order_id }}" }
}