# Analytics Providers

Analytics Providers let you attach **browser analytics and ads SDKs** to public stream pages. Stream
views and play events then appear in the tools you already use — separately from DailyPlay’s built-in
[Analytics](/sharing/analytics/) reports and from server-side [Connections](/connections/overview/)
(CRM / webhook sinks).

:::note
Configs store **public** measurement IDs and project tokens only. Never paste secret API keys or
server credentials here.
:::

---

## How It Differs From Connections and Reports

| Feature | What it does |
| :------ | :----------- |
| **Analytics Providers** | Client-side SDKs load on the player; events go to your GA4 / Mixpanel / etc. dashboards |
| **Connections** | Server-side webhooks and CRM sync (Braze, Zapier, HubSpot, …) |
| **Reports / Analytics** | DailyPlay-hosted play metrics, sessions, leads, and exports |

---

## Supported Providers

| Provider | Required fields | Optional fields |
| :------- | :-------------- | :-------------- |
| **Google Analytics** | Measurement ID (`G-…`) | — |
| **Mixpanel** | Project token | API host; Session Replay sample rate (0–100; blank defaults to 100) |
| **PostHog** | Project API key, API host (e.g. `https://us.i.posthog.com`) | — |
| **Amplitude** | API key | Server zone (`US` or `EU`; default US) |
| **Google Tag Manager** | Container ID (`GTM-…`) | — |
| **Meta Pixel** | Pixel ID | — |

You can enable multiple provider types on the same stream (one active link per type).

---

## Setting Up

Only organization **owners** and **admins** can manage analytics providers.

### 1. Add a provider (organization library)

1. Go to **Connect → Analytics** (or open `/analytics`)
2. Click **Add Provider**
3. Choose a provider type and enter a display name plus the required public IDs
4. Save — the provider is reusable across streams

Activate, deactivate, edit, or delete providers from the same page. Deleting a provider removes its
links from streams.

### 2. Enable tracking on a stream

1. Create or edit a stream
2. Open the **Tracking** step
3. Enable the provider type you want
4. Either:
   - **Use org provider** — select an existing config from your library, or
   - **Create new…** — enter a display name and fields inline (creates an org provider and links it
     when you save the stream)
5. Save the stream

Disable a type on the Tracking step to turn it off for that stream without deleting the org
provider.

---

## Events Sent to Third-Party Tools

When a linked provider is active on the public stream, DailyPlay loads its SDK and forwards:

| Event | When |
| :---- | :--- |
| Stream / page view | On SDK init (GA `page_view`; Mixpanel/Amplitude `stream_view`; GTM `dp_stream_view`; Meta `PageView`) |
| `play_start` | A player starts a game (Meta maps to `ViewContent`) |
| `play_complete` | A player finishes a game (Meta maps to `CompleteRegistration`) |
| `share` | A player shares a result |
| `cta_click` | Mapped for Meta as `Lead` where supported |

Context often includes `stream_id`, `stream_slug`, `stream_name`, `org_slug`, `player_uuid`,
`session_id`, game/score fields, and URL query params such as `utm_*`, `external_id`, and
`user_id`. Players are identified by `player_uuid` when present.

GTM receives `dp_<event>` on the dataLayer so you can route tags in your container.

---

## Privacy & Consent

- Measurement IDs appear in the public stream payload by design (required for client SDKs).
- DailyPlay does **not** gate these SDKs behind a separate cookie consent banner — ensure your own
  privacy policy and CMP cover third-party tags on stream pages.
- Stream CTA marketing consent (e.g. “I agree to receive marketing emails”) applies to lead forms,
  not to analytics SDK loading.
- Mixpanel and PostHog may use `localStorage`. Mixpanel Session Replay can record canvas gameplay
  when enabled.

---

## Managing Providers

| Action | Effect |
| :----- | :----- |
| **Activate / Deactivate** (org) | Controls whether the provider can load when linked |
| **Enable / Disable** (stream Tracking) | Turns tracking on or off for that stream |
| **Delete** (org) | Removes the provider and all stream links |
| **Unlink** (stream) | Stops tracking for that stream; org provider remains |

Both the org provider and the stream link must be active for the SDK to load on the public player.
Failed SDK loads fail soft — play continues.

---

## Agents and API Keys

Organization admins can manage providers via the [MCP server](/api/mcp/) with:

- `mcp:analytics_providers:read`
- `mcp:analytics_providers:write`

See [MCP Tools](/api/mcp-tools/#analytics-providers) for the full tool list and config shapes.

Typical agent flow:

1. `create_analytics_provider` with `provider` + public `config`
2. `link_stream_analytics_provider` with `stream_id` + `analytics_provider_id`
3. Optional per-stream `config_override`; unlink keeps the org provider

---

## Next Steps

- Review built-in [Analytics](/sharing/analytics/) and [Reports](/sharing/analytics/#reports)
- Wire CRM / webhook sinks with [Connections](/connections/overview/)
- Pass attribution params with [UTM Tracking](/streams/overview/#utm-tracking)