> For the complete documentation index, see [llms.txt](https://help.openloyalty.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.openloyalty.io/campaigns/campaigns/campaigns-and-referral-campaigns/creating-campaigns/trigger-types/custom-event.md). Agents can also search and read this documentation through its [MCP server](https://help.openloyalty.io/~gitbook/mcp).

# Custom Event

A Custom Event trigger activates when your external system sends a predefined event to Open Loyalty via API. You must first create a **Custom Event Schema**, which defines event names and optional attributes. Once the schema is in place, you can launch a **separate campaign** that responds to those custom events—fully independent from other campaign types.

***

### 🛠️ Step-by-Step Setup

{% stepper %}
{% step %}
**Create Custom Event Schema**

* Navigate to **Custom Events → Custom Event Schemas**
* Add optional attribute (e.g., `steps`) that can be used later on in the campaign rules.
* Save the schema status to **Active**

{% hint style="info" %}
For more information on how to create a custom event schema, please refer to this section of the User Guide: [Custom Event Schemas](https://help.openloyalty.io/members-and-activity/custom-events/custom-event-schemas.md)
{% endhint %}
{% endstep %}

{% step %}
**Add Campaign**

* Go to **Campaigns** or **Referral Campaigns** → ***Add campaign*** → select **Custom Event** trigger.
* Choose your event name from the schema dropdown. Attributes defined in the schema become available for use in rule conditions.
  {% endstep %}

{% step %}
**Set Basic Campaign Details**

* Name, Description, Translations
* Start/End Date, Display Order, Visibility (Everyone / Segment / Tier)
* **Campaign Status** – The campaign will start only if it is active
  {% endstep %}

{% step %}
**Add Rules**

* Add **Conditions** using `event.body.<attribute>` (e.g., filtering where `event.body.steps ≥ 5000`)
* **Effect**: e.g., "Add units: 1 × amount of steps", "Add 100 fixed points", "Issue coupon".
  {% endstep %}

{% step %}
**Set Limits & Budget**

* Per-member frequency (e.g., once per month)
* Campaign-level spending caps (total units)
  {% endstep %}

{% step %}
**Summary**

* Review the campaign configuration and amend if needed
* Click on **Add Campaign**
  {% endstep %}

{% step %}
**Test Campaign - Send Event via API**

Use `POST /api/{storeCode}/customEvent` with payload:

```json
{
  "event": {
    "type":"app_login",
    "eventDate":"2025-07-15T11:26:46.299Z",
    "customerData": { "email":"email@example.com" },
    "body": { "key":"value" }
  }
}
```

Successful sends return status 200.
{% endstep %}
{% endstepper %}

***

### ⚙️ Why Use Custom Event Campaigns

* **Flexibility**: Trigger campaigns on any behavior tracked externally—app usage, fitness milestones, third‑party integrations, and more.
* **Precision Targeting**: Use schema attributes in conditions to segment and personalize campaigns.
* **De-coupled Execution**: Events and campaigns are independent—no side effects on other systems.

***

### ✅ Best Practices

* **Define Schemas Thoughtfully**: Include only necessary attributes needed for campaign logic.
* **Test End-to-End**: Send test events via API and verify they appear under **Custom Events** in the admin UI.
* **Limit Rewards**: Use per-member and campaign-wide limits to prevent over-issuing.
* **Track Engagement**: Monitor event-driven campaign metrics to understand response rates.


---

# 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://help.openloyalty.io/campaigns/campaigns/campaigns-and-referral-campaigns/creating-campaigns/trigger-types/custom-event.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.
