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

# Analytics destinations

> Options for the GA4, Meta, TikTok, and Masivo adapters, on web and in React Native.

Each destination is a package that you pass to `adapters` in [`configure()`](https://firespark.cloud/docs/guides/analytics/use-analytics-in-the-sdk). On web, the adapters load the provider script themselves. In React Native, you pass the native SDK functions.

Every destination of one `track()` gets the same event id, so Meta and TikTok can deduplicate it against your server events. A destination failure goes to `onError` and does not affect the others.

## GA4

```bash theme={null}
pnpm add @fire-spark/analytics-ga4
```

### Web

```typescript theme={null}
import { ga4 } from "@fire-spark/analytics-ga4";

ga4({
  measurementId: "G-XXXXXXX",
  config: { send_page_view: false, debug_mode: true },
  consentDefaults: { analytics_storage: "denied", ad_storage: "denied", wait_for_update: 500 }
});
```

* `config` is passed to `gtag("config", measurementId, config)`.
* `consentDefaults` is sent as `gtag("consent", "default", …)` before the first `config`.
* Each event is sent with `send_to` set to your `measurementId`, also when the page already configures another GA4 property. Several `ga4()` adapters with different ids each receive their events.
* If the page already has `window.gtag` (the official snippet or Google Tag Manager), the adapter uses it and does not load a second gtag.js. Otherwise it creates the official stub and loads gtag.js once per page.
* If gtag.js fails to load, the event is reported with `onError` and the next event tries again.

`setUser()` becomes `gtag("set", { user_id })` and `gtag("set", "user_properties", …)`. `setConsent()` becomes `gtag("consent", "update", …)`: `analytics` maps to `analytics_storage`, and `ads` maps to `ad_storage`, `ad_user_data`, and `ad_personalization`.

### React Native (Firebase)

```typescript theme={null}
import { getAnalytics, logEvent, setConsent, setUserId, setUserProperties } from "@react-native-firebase/analytics";

const firebase = getAnalytics();

ga4({
  logEvent: (name, params) => logEvent(firebase, name, params),
  setUserId: id => setUserId(firebase, id),
  setUserProperties: properties => setUserProperties(firebase, properties),
  setConsent: consent => setConsent(firebase, consent)
});
```

Wrap the modular API as shown: its functions take the analytics instance as their first argument.

The adapter checks Firebase rules before calling `logEvent`. A reserved name (for example `session_start`), a reserved prefix (`firebase_`, `google_`, `ga_`), or an invalid name is reported with `onError` instead of being lost. More than 25 params, or values longer than 100 characters, are reported with the adapter's `onWarning`. Keys with `undefined` or `null` are removed before the call.

## Meta

```bash theme={null}
pnpm add @fire-spark/analytics-meta
```

```typescript theme={null}
import { meta } from "@fire-spark/analytics-meta";

meta({ pixelId: "1234567890" }); // web
meta({ logEvent, setUserId, setConsent }); // React Native app events
```

On web, the adapter uses the official `fbq` snippet, or the one already on the page, and sends each event only to your pixel (`trackSingle` or `trackSingleCustom`) with `eventID`. Standard events (`Purchase`, `AddToCart`) and custom events are sent with the matching call. Hashed email, phone, and user id are passed as advanced matching. `setConsent()` becomes `fbq("consent", "grant" | "revoke")`.

In React Native, `logEvent(name, params, valueToSum)` receives the event. Names must follow Meta's app event rules (up to 40 characters, letters, numbers, `_`, `-`, and spaces); an invalid name is reported with `onError`. `setUserId` receives the SHA-256 of the user id.

## TikTok

```bash theme={null}
pnpm add @fire-spark/analytics-tiktok
```

```typescript theme={null}
import { tiktok } from "@fire-spark/analytics-tiktok";

tiktok({ pixelId: "CXXXXXXXXXXXXXXX" }); // web
tiktok({ logEvent, identify, logout, setConsent }); // React Native
```

On web, the adapter uses the official `ttq` snippet. If the page already loads TikTok, it reuses it and loads your pixel there. Events go to your pixel's instance with `event_id`, after `identify` with the hashed user data. `setConsent()` becomes `ttq.grantConsent()` or `ttq.revokeConsent()`.

In React Native, `identify` receives the hashed user data and `logout` runs when the user is cleared.

## Masivo

```bash theme={null}
pnpm add @fire-spark/analytics-masivo
```

```typescript theme={null}
import { masivo } from "@fire-spark/analytics-masivo";

masivo({ publishableKey: "pk_live_..." });
masivo({ publishableKey, track: (type, body) => client.track(type, body) });
```

Without `track`, the adapter uses the Masivo SDK already on the page (`window.masivo`) and reports an error if it is missing.

The adapter sends the body of Masivo's [Emit event](https://docs.masivo.ai/api-reference/behavior/events/post), as described in [Send an event](https://docs.masivo.ai/api-reference/guides/send-an-event). The event name is the Masivo `type` (for example `PURCHASE` or `ADD_TO_CART`). `customer_id`, `brand_id`, and `type` are required: an event without them is reported with `onError` and not sent.

| Fire Spark | Masivo body |
| - | - |
| Customer | `customer_id` |
| Brand from `getScope()` | `brand_id` |
| Always `firespark` | `platform` |
| Event time | `issued_at` |
| `order_id` or `transaction_id` (`PURCHASE`) | `order.purchase_id` |
| `value` (`PURCHASE`) | `order.value` |
| `items` (`PURCHASE`) | `order.products`: `sku` (`item_id`), `amount` (`quantity`), `value` (price × quantity) |
| `payment_method` (`PURCHASE`) | `order.payment_method`: `CASH`, `BANK_TRANSFER`, or `OTHER` |
| Store and channel | `order.store_id`, `order.channel_id`, and `metadata` |
| First item (`ADD_TO_CART`) | `product` |
| UTM params, click ids (`gclid`, `fbclid`, `ttclid`) | `attribution` |
| Currency and any other param | `metadata` |
| Rewards redeemed in the order's tenders | `metadata.redemptions` |

Amounts are computed with exact decimals and never rounded. Raw email and phone, and the order's raw tenders, are never sent to Masivo. In the dashboard tracking plan, Masivo params are these body paths, and a path outside the Emit event body shows a warning.


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