Overview

This document outlines the process for sending event tracking data to Dema from the server-side. It covers the setup for tracking both pageview and order events via HTTP requests, ensuring you can effectively track user interactions without relying on client-side mechanisms.

Requirements to setup server side tracking

Before integrating Dema scripts into your website, ensure the following prerequisites are met:

  • Ecommerce System Matching: The product ID should match the one in your ecommerce system.
  • Dema ID: You need your unique Dema ID, formatted as DV-XXXXXXXXXXXXXXXXXXXXXXXX.

Request Details

Endpoint

  • URL: https://tracker.dema.ai/track.js

HTTP Method

  • Method: GET

Headers

  • User-Agent: Client’s User Agent string to be included in the request headers.

Request Parameters

Common Parameters for All Events

  • e: Event type. Accepts "pageview" or "order".
  • i: Your unique Dema ID.
  • v: Version of your tracking script (e.g., "1.0.0").
  • uid: Unique user ID for the event, a UUID managed server-side.
  • _nc: Current timestamp.
  • u: The full URL of the page visited.
  • r: The referring URL, if available.

Event-Specific Parameters

  • m: Additional event data in JSON string format.
Pageview Event

For a pageview on a product page, include:

{
  "productId": "1234",
  "ip": "127.0.0.1",
  "country": "SE"
}
Order Event

For an order event, include detailed order information:

{
  "order": {
    "orderId": "1234ORDER",
    "total": "99.02",
    "shipping": "13.03",
    "currency": "EUR",
    "tax": "23.00",
    "voucher": "",
    "products": [
      {
        "id": "1234",
        "productId": "12345",
        "price": "1239.0",
        "quantity": 1
      }
    ],
    "customer": {
      "idFields": {
        "customerId": "testcustomer@teststore.se"
      }
    }
  },
  "ip": "127.0.0.1",
  "country": "SE"
}

Examples of Curl Requests

curl 'https://tracker.dema.ai/track.js?e=pageview&m=%7B%22productId%22%3A%221234%22%2C%22ip%22%3A%22127.0.0.1%22%7D&u=https%3A%2F%2Fexample.com&i=YOUR-DEMA-ID&v=1.0.0&uid=YOUR-UUID&_nc=YOUR-TIMESTAMP' \
-H 'User-Agent: CLIENT-USER-AGENT'
Replace placeholder values (YOUR-DEMA-ID, YOUR-UUID, YOUR-TIMESTAMP, and CLIENT-USER-AGENT) with actual data specific to your implementation.

Additional Notes

  • Ensure all URL parameters are properly URL-encoded. The examples provided have been encoded accordingly.
  • The management of the unique user ID (uid) must be handled server-side. This ID should be consistent across different events to track user behavior accurately.