> For the complete documentation index, see [llms.txt](https://docs.buildnatively.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.buildnatively.com/guides/integration/custom-event.md).

# Custom Event

### Prerequisites

* The Analytics feature must be enabled for your app. Follow this guide for setup: [Analytics](/natively-platform/features/analytics.md)
* Availability:
  * Bubble Plugin Version: 2.25.0 or higher
  * JavaScript SDK Version: 2.19.1 or higher

### Bubble.io Plugin

**\[Action]** Natively - Send Custom Event

* Event name - The unique identifier that will appear in your Analytics dashboard. (e.g., `user_onboarded`, `checkout_started`)
* Event data - A JSON object containing custom parameters and values you want to send with the event

#### Usage Example (Bubble Workflow)

1. In your workflow, add the action: `Natively - Send Custom Event`.
2. Provide the Event name.
3. Provide the Event data as a JSON object (must be valid JSON).  Example:&#x20;

```json
{
  "user_id": "12345",
  "screen": "home",
  "duration_seconds": 45,
  "is_premium_user": true
}
```

<figure><img src="/files/Pm0OEYQFKyCJIVhJ5zJM" alt=""><figcaption></figcaption></figure>

#### Result:&#x20;

The event and its custom parameters will be recorded in your Analytics dashboard.

<figure><img src="/files/IeJJZvZqcxkOhoziTDpI" alt=""><figcaption></figcaption></figure>

### JavaScript SDK

Use the `natively.analyticsTrackEvent()` method to send the event name and a JavaScript object containing the custom data.

Example:&#x20;

```javascript
// 1. Define custom parameters using a Map
const eventData = new Map();
eventData.set('user_id', '12345');
eventData.set('screen', 'home');
eventData.set('duration_seconds', 45);
eventData.set('is_premium_user', true);

// 2. Send the event
natively.analyticsTrackEvent('button_clicked', Object.fromEntries(eventData));
```

### How to Test in AppsFlyer

1. Add the test device to your AppsFlyer account. Follow this guide: [here](https://support.appsflyer.com/hc/en-us/articles/207031996-Registering-test-devices#register-a-device-manually)
2. In the AppsFlyer dashboard, go to Settings > SDK Integration Test > Live events.<br>

   <figure><img src="/files/wHae5oGnEnn7O1ZeUxmX" alt=""><figcaption></figcaption></figure>
3. Select your app and the test device, then click Continue.<br>

   <figure><img src="/files/hrKAWIM2gxfCXrb42YMK" alt=""><figcaption></figcaption></figure>
4. Start the event listener. Launch the app on the test device and trigger the custom event (e.g., click the button associated with the event).

<figure><img src="/files/BFy9psuP7M1yscvWe8uT" alt=""><figcaption></figcaption></figure>

#### **Result:**&#x20;

You will see the custom event and its associated data registered in the AppsFlyer Live Events dashboard.

<figure><img src="/files/IeJJZvZqcxkOhoziTDpI" alt=""><figcaption></figcaption></figure>
