> For the complete documentation index, see [llms.txt](https://everyday-digital.gitbook.io/falkor-dev-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://everyday-digital.gitbook.io/falkor-dev-docs/pathways/webtracking/server-api.md).

# Server-Side Platforms

The **Web Tracking API** can also be integrated on server-side platforms -  perfect if you wish to **track** [**pathway**](https://docs.falkor.io/pathways/create-a-pathway) **activities in an external LMS** or **any server-based platform**.

In this scenario, you will be able to have more fine-grained **control** with **deeper integration options.**

### Examples of Server-Side Web Activities

* **LMS**. You would like to integrate course enrolment into a web activity, and/or you want users to complete a course on an LMS in order to mark the activity as complete on their [pathway](https://docs.falkor.io/pathways/create-a-pathway).<br>
* **Utility Platforms**. You have a performance or work utility platform and would like users to reach certain milestones or KPIs before the pathway activity is marked as complete.<br>
* **Profile Setups.** You want to automate user profile setups and sign-ins on your platform.

## Automating Profile Setups & Routing

With a server-side platform, you may want to **automate user registration and sign-on for the web activity**. This is possible by using the **pull endpoint**. As the user reaches the provided URL, you will be able to use the `webToken` to **pull user information**. The pull endpoint will provide `user` object, which contains a `userToken` and available personal information such as `email` which can be used to identify or register a user.

The pull endpoint will additionally provide `activity` object, which contains an `ID` **identifier** and **activity** `name`. This identifier is provided during a [Web Activity](https://docs.falkor.io/pathways/pathway-activities/web-activity) setup and is used to allow an **external reference to your platform**. This is useful to where you would want to redirect users to a specific area on your platform e.g. course, task, or page.

## Pull Data

The pull endpoint for [web activities](https://everyday-digital.gitbook.io/falkor-dev-docs/pathways/webtracking) provides the following platform user details:

1. firstname
2. surname
3. email
4. userToken (unique ID for user)

```
curl -X POST \
  v1/webtracking/pull \
  -H 'Authorization: Basic <Your Base64 Encoded Token>' \
  -d '{
	"webToken" : "<webToken>"
}'
```

### Parameters

| Key          | Type                                     |
| ------------ | ---------------------------------------- |
| **REQUIRED** |                                          |
| **webToken** | String (get parameter added to the URL). |

### Response

```
{
    "status": "success",
    "data": {
        "activity": {
            "name": "Push the button",
            "ID": "FAWT-FQPT-79TC"
        },
        "pathway" : {
            "name": "Pathway A",
            "ID"  : "EV67-ZCNS-56AD"
        }
        "user": {
            "userToken": "5cc31a662c1ce7d78ac75b2bf4a9a40f",
            "email": "test@example.com",
            "firstname": "Falkor",
            "lastname": "Developer"
        },
        "progress": 0,
        "complete": false,
        "data": "",
        "message": ""
    },
    "hash": "510964a04becda2bae678f3e3727825e",
    "response_time": 0.1087651252746582
}
```

<table data-header-hidden><thead><tr><th width="173">Key</th><th>Type</th></tr></thead><tbody><tr><td><strong>Key</strong></td><td><strong>Type</strong></td></tr><tr><td><strong>activity</strong></td><td>Object. Name and ID of the activity.</td></tr><tr><td><strong>pathway</strong></td><td>Object. Name and ID of the pathway.</td></tr><tr><td><strong>user</strong></td><td>Object. User information and unique userToken.</td></tr><tr><td><strong>progress</strong></td><td>Float. The stored user's progress as a percentage from 0 to 100.</td></tr><tr><td><strong>message</strong></td><td>String. A stored message string (max. 48 characters).</td></tr><tr><td><strong>data</strong></td><td>Object. A stored data result as a JSON string.</td></tr></tbody></table>

{% content-ref url="/pages/-MJVhUdHCvGDd4CgxsLl" %}
[User Privacy](/falkor-dev-docs/overview/user-privacy.md)
{% endcontent-ref %}

## Push Data

When it comes to **pushing data**, you can either use the `webToken` or a combination of the `userToken` and the activity `activity_ID` (identifier). This will be dependant on **how you plan to store tokens and interact with the push endpoint**. To give some scenarios, you could:

* **Store a Session.** As the user accesses the URL from the pathway you can store the `webToken` as a session and make subsequent calls to the push endpoint using the session stored `webToken`. This makes the most sense if the activity is likely to update while the user is on your platform. <br>
* **Use the activity\_ID with the userToken.** You can also make calls to the push endpoint by using the `activity_ID` in combination with the `userToken`. As the `activity_ID` (API Identifier) is something you would provide during the [Web Activity](https://docs.falkor.io/pathways/pathway-activities/web-activity) setup, you would only need to devise logic to store the `userToken` to a profile on your platform. This makes the most sense if the activity is likely to update whether the user is or is not on your platform.

### Parameters Using The `webToken`

```
curl -X POST \
  v1/webtracking/push \
  -H 'Authorization: Basic <Your Base64 Encoded Token>' \
  -d '{
    "webToken": "<webToken>",
    "progress": 80,
    "completed": 0,
    "message": "Custom Message",
    "data": "{\"buttonPushes\":8}"
}'
```

| Key          | Type                                                           |
| ------------ | -------------------------------------------------------------- |
| **webToken** | String                                                         |
| **progress** | Float. The stored user's progress as a percentage of 0 to 100. |
| **complete** | Int. The stored user's completion state. 1 = true, 0 = false.  |
| **message**  | String. A stored result string (max. 48 characters).           |
| **data**     | String. A JSON string of data to store.                        |

### Parameters Using the `userToken` with `activity_ID`

```
curl -X POST \
  v1/webtracking/push \
  -H 'Authorization: Basic <Your Base64 Encoded Token>' \
  -d '{
    "pathway": "<Name or ID of Pathway>",
    "userToken": "<User Token>",
    "activity_ID": "<Activity ID>"
    "progress": 80,
    "completed": 0,
    "message": "Custom Message",
    "data": "{\"buttonPushes\":8}"
}'
```

<table data-header-hidden><thead><tr><th width="150">Key</th><th width="599.4285714285713">Type</th></tr></thead><tbody><tr><td><strong>Key</strong></td><td><strong>Type</strong></td></tr><tr><td><strong>userToken</strong></td><td>String</td></tr><tr><td><strong>pathway</strong></td><td>String. The name or ID of the related pathway</td></tr><tr><td><strong>activity_ID</strong></td><td>String. The API Identifier the web activity is setup with.</td></tr><tr><td><strong>progress</strong></td><td>Float. The stored user's progress as a percentage of 0 to 100.</td></tr><tr><td><strong>complete</strong></td><td>Int. The stored user's completion state. 1 = true, 0 = false.</td></tr><tr><td><strong>message</strong></td><td>String. A stored result string (max. 48 characters).</td></tr><tr><td><strong>data</strong></td><td>String. A JSON string of data to store.</td></tr></tbody></table>

### Success Response

The **response** will contain `pushed` indicating that the data has been updated along with the current `progress` and `complete` **state**.

```
{
    "status": "success",
    "data": {
        "pushed": true,
        "progress": 80,
        "complete": false
    },
    "hash": "c5fa8b54843a16cbbe33688977f2bd02",
    "response_time": 0.12575912475585938
}
```

### API Endpoint

When API account is generated, the base endpoint is provided in the JSON file. Example:

```
{
    "name": "API Account Example",
    "app_id": "FAPW-IGVH-45ZU",
    "token": "b94e123b...",
    "endpoint": "https://api.platformname.io/"
}
```
