> For the complete documentation index, see [llms.txt](https://user.netmera.com/netmera-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/tracking-custom-events.md).

# Tracking Custom Events

Read the event schema of the application, then send a custom event for a user from your backend.

This recipe shows how to look up the event definitions of your application and send a custom event for a user from your own system. Events sent from your backend appear in Netmera in the same way as events collected by the SDK, so they can be used for analytics and targeting.

## When to Use

This recipe fits actions that your backend knows about but the mobile app does not see, such as a cancelled order, a completed payment, or a status change in another system.

## Prerequisites

* REST API key of the application
* The external ID (`extId`) of the user the event belongs to
* The event and its attributes defined in the Netmera panel. Attributes sent with an event must match the event schema defined in the panel.

## Step 1: Read the Event Definitions

List the event definitions of the application with `app/events`. The response is read-only and shows which events exist and which attributes each event expects.

```bash
curl https://restapi.netmera.com/rest/3.0/app/events \
  --header 'X-netmera-api-key: <API_KEY>'
```

`standardEvents` contains the built-in events exposed to your application and `customEvents` contains the events defined in the panel. Each definition lists its own `attributeDefinitions` and the `inheritedAttributes` of its base event. Note the `code` of the event, which is the value used when the event is fired, and check which attributes are marked `mandatory`.

**Expected result:** The event you want to send is listed, together with the names and data types of its attributes.

## Step 2: Fire the Event

Send the event to `fireEvents`. The body is a JSON array, so several events can be sent in one request. Each object requires `extId`, to identify the user, and `name`, to specify the event. All other fields are attributes of the event.

```bash
curl https://restapi.netmera.com/rest/3.0/fireEvents \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '[
  {
    "extId": "user_1001",
    "name": "OrderCancelEvent",
    "paymentMethod": "Credit Card",
    "subTotal": 20.0,
    "itemCount": 4,
    "grandTotal": 35.0
  }
]'
```

{% hint style="info" %}
The attributes in this example, such as `paymentMethod` and `grandTotal`, must exist in the event schema in the Netmera panel. Use the attribute names returned in Step 1.
{% endhint %}

**Expected result:** The request is sent with the event name and attributes exactly as defined in the schema.

## Verification Checklist

* `extId` is the same value that the SDK or `registerUsers` assigned to the user
* `name` matches the event code returned by `app/events`
* Every attribute in the request exists in the event schema, with a matching data type
* Attributes marked `mandatory` in the definition are included
* The request body is a JSON array, even for a single event

## Related Pages

For the request format of custom events, see [Events](/netmera-developer-guide/api-documentation/rest-api/events.md) in the REST API documentation. For the response format of the event definitions, see [Application Data](/netmera-developer-guide/api-documentation/rest-api/application-data.md). To register the users that these events belong to, see [Registering Users and Building a Profile](/netmera-developer-guide/api-documentation/recipes/registering-users-and-profiles.md). To connect a conversational AI app to Netmera with events, see [Conversational AI Apps with Netmera](/netmera-developer-guide/api-documentation/rest-api/conversational-ai-apps-with-netmera.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/tracking-custom-events.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
