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

# Meta App Events

> Track Meta App Events in your app with the native iOS and Android Meta SDKs, including auto-logged, custom, and purchase events.

The Meta App Events plugin embeds the native iOS and Android Meta (Facebook) SDKs directly into your Median-wrapped app. This gives you access to Facebook App Events — Meta's analytics and ad measurement system — without relying on the web-based Facebook Pixel. You can capture standard events like App Install and App Launch automatically, and send fully custom events from your web content using the JavaScript Bridge. Because the events flow through the native SDKs, you get more reliable data collection and a broader set of measurable actions than the Pixel alone can provide.

> [!TIP]
>
> **Test  with our demo page**
>
> We host a ready-made demo page at
>
> that calls the  features through the Median JavaScript Bridge.
> Load it inside your Median app during development, either by setting it
> as your app's website URL in App Studio or by navigating to it from your
> own site, and use it to confirm  works on a real device before
> you add it to your own pages.
>
> The demo page only works inside a Median app with  enabled.
> Opened in a regular mobile or desktop browser, the native features
> won't respond. Remember to switch your app back to your own URL before
> release.

## Why use Meta App Events?

* **Auto events**: Enable auto logging for standard events such as App Install and App Launch.
* **Custom events**: Send custom events (e.g. level achieved, purchases) via the JavaScript Bridge.
* **Native SDKs**: iOS and Android Meta SDKs integrated by Median App Studio when enabled and configured.
* **Ad performance**: Measure Meta Ad performance and build audiences for Meta Ad targeting using the Facebook SDK.

## Prerequisites

* [ ] A Median app with the JavaScript Bridge enabled
* [ ] A Facebook Application created in the [Facebook Developer Account](https://developer.facebook.com/) (for Android, add your app's release key hash from Median App Studio under **Facebook App Events**)
* [ ] Facebook Application ID and Facebook Display Name from your Facebook Developer Account

## Integration guide

### Plugin enablement

1. **Create a Facebook Application** within your [Facebook Developer Account](https://developer.facebook.com/). For Android, add your app's release key hash (found in Median App Studio under **Facebook App Events**).
2. **Configure in Median App Studio**: Add your Facebook Application ID and Facebook Display Name from your Facebook Developer Account to your Median app's configuration.

Follow the steps above in the Facebook Developer console and in **Native Plugins → Facebook App Events** in App Studio.

#### Configuration options

| Setting | Description |
| - | - |
| **Facebook Application ID** | From your Facebook Developer Account |
| **Facebook Display Name** | From your Facebook Developer Account |
| **Auto logging** | Enable in plugin settings, or set `services.facebook.autoLogging: true` in appConfig.json |

### JavaScript Bridge functions

#### Auto events

Enable or disable auto logging for standard events (e.g. App Install, App Launch).

Median JavaScript Bridge

```javascript JavaScript  theme={null}
median.facebook.setAutoLogging(true); 
```

**Parameters:**

| Parameter | Type | Required | Description |
| - | - | - | - |
| Auto logging flag | `boolean` | Yes | `true` to enable, `false` to disable |

#### Custom events

##### Regular events

Send a custom event to Facebook. Create a JavaScript object with:

* **event** (required): String that identifies the event type.
* **valueToSum** (optional): A number to sum up.
* **parameters** (optional): Object of additional parameters.

Median JavaScript Bridge

```javascript JavaScript theme={null}
var data = {
  event: "fb_mobile_level_achieved",
  parameters: { fb_level: "1" },
};
median.facebook.events.send(data);
```

**Parameters:**

| Parameter | Type | Required | Description |
| - | - | - | - |
| `data.event` | `string` | Yes | Event name |
| `data.valueToSum` | `number` | No | Optional aggregate value |
| `data.parameters` | `object` | No | Optional key-value parameters |

Event name and parameter key constants can be found in the Facebook SDK source (Android: `AppEventsConstants.kt`; iOS: `FBSDKAppEvents.m`).

#### Purchase events

Send a purchase event. Facebook's SDK sends purchase events more immediately than regular events.

Median JavaScript Bridge

```javascript JavaScript theme={null}
var data = {
  purchaseAmount: 2.56,
  currency: "USD",
};
median.facebook.events.sendPurchase(data);
```

**Parameters:**

| Parameter | Type | Required | Description |
| - | - | - | - |
| `purchaseAmount` | `number` | Yes | Purchase amount |
| `currency` | `string` | Yes | ISO 4217 currency code (e.g. `'USD'`) |

## Testing checklist

Use this checklist to verify Meta App Events is working correctly before going to production:

**Basic functionality**

* [ ] Facebook Application created in the [Facebook Developer Account](https://developer.facebook.com/)
* [ ] Facebook Application ID and Display Name added in Median App Studio
* [ ] For Android: app release key hash added to the Facebook Developer Account under your app's Android settings
* [ ] Plugin is enabled in Median App Studio and a new app build has been generated

**Platform testing**

* [ ] `setAutoLogging(true)` executes without JavaScript errors
* [ ] App Install event appears in Meta Events Manager after a fresh install
* [ ] App Launch event appears in Meta Events Manager after opening the app
* [ ] `setAutoLogging(false)` disables auto logging as expected

**Configuration testing**

* [ ] `median.facebook.events.send()` runs without errors and events appear with correct names
* [ ] `median.facebook.events.sendPurchase()` records `purchaseAmount` as a **number** and `currency` as a valid ISO code

**User experience**

* [ ] All functions are called after `median_library_ready()`
* [ ] JavaScript Bridge is enabled on both iOS and Android test builds

## Troubleshooting

### Meta App Events functions are undefined or not working

Ensure the **JavaScript Bridge is enabled** in App Studio. Call all `median.facebook.*` functions after the `median_library_ready()` event fires. Calling them earlier results in undefined errors.

Also confirm:

* The plugin is enabled in Median App Studio
* A new app build has been generated after enabling the plugin
* Your **Facebook Application ID** and **Display Name** are correctly entered in Median App Studio

### Events are not appearing in Meta Events Manager

Event delivery can be delayed by up to 15–20 minutes in Meta Events Manager. If events are still missing after waiting:

* Verify your **Facebook Application ID** matches the app you're checking in Meta Events Manager
* Confirm the event call is executing (add a `console.log` before the `median.facebook.events.send()` call to verify)
* Check that the `event` field in your data object uses a valid event name string — typos will cause events to be dropped silently

### Android: events not firing or app crashes on launch

Android requires your app's **release key hash** to be registered in your Facebook Application settings. Without it, the Meta SDK will fail to initialize on release builds.

To fix this:

1. In Median App Studio, navigate to **Facebook App Events** and copy your release key hash
2. In your [Facebook Developer Account](https://developer.facebook.com), go to your app → **Settings → Basic → Android** and add the key hash
3. Generate a new app build after making this change

### Auto logging is enabled but app install / app launch events are missing

Confirm that `setAutoLogging(true)` is being called after `median_library_ready()` and before any navigation or lifecycle events you want to capture. App Install events in particular are only sent on the **first launch** after installation — reinstalling the app is required to trigger it again during testing.

Also verify that auto logging hasn't been disabled elsewhere in your code with a `setAutoLogging(false)` call.

### Purchase events are not recorded with the correct amount or currency

Ensure the `purchaseAmount` field is passed as a **number** (not a string) and that `currency` uses a valid [ISO 4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) (e.g. `'USD'`, `'EUR'`, `'GBP'`). Passing an incorrect type or unsupported currency code will cause the event to be dropped or recorded incorrectly.

Median JavaScript Bridge

```javascript JavaScript theme={null}
var data = {
  purchaseAmount: 2.56, // number, not "2.56"
  currency: "USD", // ISO 4217 currency code
};
median.facebook.events.sendPurchase(data);
```

> [!NOTE]
>
> **Still having trouble?**
>
> For Meta SDK and App Events behavior outside Median’s bridge, refer to the [Meta App Events documentation](https://developers.facebook.com/docs/app-events).


## Related topics

- [Analytics](https://docs.median.co/docs/analytics.md)
- [Changelog](https://docs.median.co/docs/changelog.md)
- [Changelog archive](https://docs.median.co/docs/changelog-archive.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.