# Receive engagement events in your own analytics

Capture what members watch and do inside Genuin views as events in your own analytics: live from the SDKs, and in batches to your warehouse.

Genuin records an event for what members do in its views: views, plays, searches, joins, posts, comments, shares, and app actions. You can receive them two ways. The SDKs expose a callback that fires as events are recorded, for your in-app analytics. Brand Control Center exports the full event history to a warehouse on a schedule, for reporting and joins with your own data. When you finish, Genuin events arrive in your analytics tool from the SDK, and your warehouse receives the history.

## Before you begin

- **A Genuin view in your product**: a Web SDK embed, or the iOS or Android SDK. See [Embed the Genuin Web SDK on your website](https://begenuin.com/developers/developer-resources/sdk/how-do-you-embed-and-configure-the-genuin-web-sdk-on-your-website), [Integrate the Genuin iOS SDK](https://begenuin.com/developers/developer-resources/sdk/developer/genuin-sdk/native-compatibility/ios/how-to-integrate-and-power-your-brand-community-in-ios-apps), and [Integrate the Genuin Android SDK](https://begenuin.com/developers/developer-resources/sdk/how-to-integrate-and-power-your-brand-community-in-android-apps).
- **An analytics destination** with a `track(name, properties)` style call, such as your product analytics tool.
- **For the warehouse export**: Create or Edit permission on **Settings** > **Data Sources** in Brand Control Center, and a BigQuery dataset, an S3 bucket, or a Mixpanel project.

## Step 1: Subscribe to events in the SDK

Each SDK has one hook that fires with the event name and its properties. Forward both to your tool.

```js title="Web"
window.genuin.on("onAnalyticsTrack", (event) => {
  const { eventName, eventPayload } = event.payload;
  analytics.track(eventName, eventPayload);
});
```

```swift title="AppDelegate.swift"
import GenuinCore

extension AppDelegate: GenuinAnalyticsDelegate {
    func onAnalyticsEvent(eventName: String, properties: [String: Any]) {
        Analytics.track(eventName, properties: properties)
    }
}

// After GenuinSDK.shared.initialize(...):
GenuinSDK.shared.analyticsDelegate = self
```

```kotlin title="MyApplication.kt"
import com.begenuin.core.GenuinSDK
import com.begenuin.core.core.interfaces.GenuinEventCallback

GenuinSDK.registerEventCallback(object : GenuinEventCallback {
  override fun onEventCallback(name: String, properties: HashMap<String, Any>) {
    Analytics.track(name, properties)
  }
})
```

| Platform | Hook | Fires | Notes |
| --- | --- | --- | --- |
| Web SDK 2.0.6 | window.genuin.on("onAnalyticsTrack", handler) | While the embed is on the page | on returns a function that unsubscribes. The handler receives event.type and event.payload with eventName and eventPayload. |
| iOS SDK 2.1.5 | GenuinSDK.shared.analyticsDelegate | While a Genuin view or screen is shown | The delegate is held weakly; keep a strong reference to the object you assign. |
| Android SDK 2.1.5 | GenuinSDK.registerEventCallback(callback) | While a Genuin view or screen is shown | Register once after initSDK. |

The callbacks fire for the events the SDK itself records, so you see the same activity Genuin's reports are built on, as it happens, for the member using your app.

## Step 2: Forward with your own identity

Genuin identifies the member by its own account. When members sign in through Auto Login or single sign-on, you already know who they are, so attach your user id to the forwarded event in your tool. That lets you join Genuin events with the rest of a user's journey in your product. See [Choose how members sign in to the Genuin SDK](https://begenuin.com/developers/developer-resources/sdk/user-authentication-mechanisms-in-genuin-sdk).

## Step 3: Export the history to your warehouse

The SDK hooks only see one member on one device. For every member, every surface, and the past, connect a data source in Brand Control Center under **Settings** > **Data Sources**. Rows arrive in batches on the daily, weekly, or monthly schedule you pick.

| Destination | What you get | Set it up |
| --- | --- | --- |
| BigQuery | One table, genuin_data, with 145 nullable columns: the event, the app and device context, member actions, playback, campaign fields, and joined community, group, video and brand records | Settings > Data Sources > BigQuery: a Dataset ID, a User or Service account, and a sync frequency |
| Amazon S3 | The same export as CSV or Parquet files in your own bucket | Settings > Data Sources > S3 Storage, Push data tab: bucket, access key, secret, frequency, and file format |
| Mixpanel | Events synced into a Mixpanel project through a service account | Settings > Data Sources > Mix Panel: service account username and secret, project ID, and frequency |

## Step 4: Run a first query

Once BigQuery is connected, see which events your communities produce before building reports on them. Replace `project_id.dataset_name` with your Dataset ID.

```sql title="Events per day"
SELECT
  DATE(_timestamp) AS day,
  event,
  COUNT(*) AS events
FROM `project_id.dataset_name.genuin_data`
WHERE _timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
GROUP BY day, event
ORDER BY day DESC, events DESC;
```

The `master_*` columns are joined from Genuin's own records, so filters such as `WHERE master_community_handle = 'trail-runners'` work without a second table. Run `SELECT column_name FROM project_id.dataset_name.INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'genuin_data'` to list every column.

## Limitations

- **SDK hooks are per device and per session.** They fire only while a Genuin view or screen is on screen in your app or page.
- **Exports are batch, not real time.** The schedule is daily, weekly, or monthly; a day of events arrives on the next run.
- **Event names aren't published as a list.** Discover them with the query above, and expect new ones with product releases.
- **One warehouse destination of each kind per brand.**

## See also

- [Embed the Genuin Web SDK on your website](https://begenuin.com/developers/developer-resources/sdk/how-do-you-embed-and-configure-the-genuin-web-sdk-on-your-website)
- [Receive zero-party data in BigQuery](https://begenuin.com/developers/developer-resources/api/connect-bigquery-to-the-brand-control-center-to-receive-zero-party-data)
- [Query Genuin event data in BigQuery](https://begenuin.com/developers/developer-resources/api/integrate-google-bigquery-with-brand-control-center)
