> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dema.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Server-side tracking (deprecated)

> This guide outlines the process for sending event tracking data to Dema from the server-side, covering pageview and order events via HTTP requests.

### Supported data types

<CardGroup cols={2}>
  <Card title="Pageviews" icon="eye">
    Product page visits
  </Card>

  <Card title="Orders" icon="file-invoice-dollar">
    Purchase transactions
  </Card>
</CardGroup>

## Prerequisites

* The product ID must match the one in your e-commerce system
* 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:

```json theme={null}
{
  "productId": "1234",
  "ip": "127.0.0.1",
  "country": "SE"
}
```

##### Order event

For an order event, include detailed order information:

```json theme={null}
{
  "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

<CodeGroup>
  ```curl Pageview Event theme={null}
  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'
  ```

  ```curl Order Event theme={null}
  curl 'https://tracker.dema.ai/track.js?e=order&m=%7B%22order%22%3A%7B%22orderId%22%3A%221234ORDER%22%2C%22total%22%3A%2299.02%22%2C%22shipping%22%3A%2213.03%22%2C%22currency%22%3A%22EUR%22%2C%22tax%22%3A%2223.00%22%2C%22voucher%22%3A%22%22%2C%22products%22%3A%5B%7B%22id%22%3A%221234%22%2C%22productId%22%3A%2212345%22%2C%22price%22%3A%221239.0%22%2C%22quantity%22%3A1%7D%5D%2C%22customer%22%3A%7B%22idFields%22%3A%7B%22customerId%22%3A%22testcustomer%40example.com%22%7D%7D%7D%2C%22ip%22%3A%22127.0.0.1%22%7D&i=YOUR-DEMA-ID&v=1.0.0&uid=YOUR-UUID&_nc=YOUR-TIMESTAMP' \
  -H 'User-Agent: CLIENT-USER-AGENT'
  ```
</CodeGroup>

<Note>Replace placeholder values (YOUR-DEMA-ID, YOUR-UUID, YOUR-TIMESTAMP, and CLIENT-USER-AGENT) with actual data specific to your implementation.</Note>

### 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.
