# Run Alongside Firebase Analytics (/docs/sdk/migration-firebase)



Firebase Analytics is a good product-analytics tool. Layers does NOT
replace it. Recommended pattern: **run both**.

## Roles [#roles]

| Tool                   | Purpose                                                                                     |
| ---------------------- | ------------------------------------------------------------------------------------------- |
| **Layers**             | Ad attribution (Meta / TikTok / Apple Search), organic content, UGC, paid media management. |
| **Firebase Analytics** | Product analytics — funnel, retention, cohorts, custom dashboards.                          |

Both can ingest the same events. They don't conflict.

## Pattern [#pattern]

Wrap your event-firing in a single function:

```ts
async function trackEvent(name: string, properties: Record<string, unknown>) {
  await layers.track(name, properties);
  firebase.analytics().logEvent(name, properties);
}
```

One call site, two destinations.

## Naming & property limits [#naming--property-limits]

Firebase has strict rules: event names up to 40 chars, parameter keys
up to 40 chars, specific reserved prefixes (`firebase_*`, `google_*`,
`ga_*`). Layers is more permissive, but pick names that satisfy
Firebase's constraints if you're going to dual-fire — it keeps your
call sites identical.

## Consent [#consent]

Firebase has `setAnalyticsCollectionEnabled`. Layers has `setConsent`.
Wire both to your CMP:

```ts
function applyConsent(granted: boolean) {
  layers.setConsent({ analytics: granted, advertising: granted });
  firebase.analytics().setAnalyticsCollectionEnabled(granted);
}
```

## Bundle size [#bundle-size]

Both SDKs add native code on RN apps. Exact impact depends on versions
and which Firebase modules you pull in (Analytics, Crashlytics, etc.).
Measure in your app; per-SDK claims in prior versions of this page
were not measured.
