---
updatedAt: 2026-03-11T09:47:16.000Z
agentTools:
  projectIndex: https://developers.openweb.com/llms.txt
---

# Analytics

The React Native OpenWeb SDK provides analytics tracking capabilities through the `OpenWeb.manager.analytics` API, enabling developers to monitor user interactions and integrate with business intelligence systems.

The analytics API consists of two key components:

* **Custom BI Data**: A customizable property for adding your own metadata to analytics events
  ```typescript
  get customBIData(): Record<string, string>
  set customBIData(value: Record<string, string>)
  ```
* **Event Handlers**: Callback registration for receiving analytics events
  ```typescript
  onAnalyticsEvent(handler: OWAnalyticsHandler): () => void
  ```

## Event Handlers

Register a handler to receive analytics events:

```typescript
const unsubscribe = OpenWeb.manager.analytics.onAnalyticsEvent((data) => {
  console.log('Analytics event:', data);
  // Send to your analytics platform
});

// Cleanup when no longer needed
unsubscribe();
```

## Custom Data in Analytics Events

The customData field in `OWAnalyticsEventData` contains your custom business intelligence data that was set via `OpenWeb.manager.analytics.customBIData`. This allows you to attach application-specific metadata to every analytics event. It's automatically included with every analytics event, allowing you to enrich your analytics with contextual information about the user, session, or application state.

```typescript
get customBIData(): Record<string, string>
set customBIData(value: Record<string, string>) 
```

```typescript
// Set custom business intelligence data
OpenWeb.manager.analytics.customBIData = {
  userId: '12345',
  userTier: 'premium',
  sessionId: 'abc-def-ghi',
  appVersion: '2.1.0'
};

// Custom data is automatically included in all analytics events
OpenWeb.manager.analytics.onAnalyticsEvent((data) => {
  console.log('Event:', data.eventName);
  console.log('Custom Data:', data.customData);
});

```

## &#x20;Type Definition

### OWAnalyticsEventData

```typescript
interface OWAnalyticsEventData {
  event: OWAnalyticsEvent;           // The specific event with its data
  postId: string;                    // Unique article identifier
  customData?: Record<string, any>;  // Your custom BI data
}
```

### OWAnalyticsEvent

<Table align={["left","left"]}>
  <thead>
    <tr>
      <th>
        Event Type
      </th>

      <th>
        Additional Data
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `FullConversationLoaded`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `FullConversationLoaded`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `FullConversationViewed`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `PreConversationViewed`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `CommentViewed`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentShareClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentReadMoreClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentRankUpButtonClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentRankDownButtonClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentRankUpUndoButtonClicked`**
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentRankDownUndoButtonClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentMenuClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentMenuClosed`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentMenuReportClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentMenuDeleteClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentMenuConfirmDeleteClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentMenuEditClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `CommentMenuMuteClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `PostCommentClicked`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `PostReplyClicked`
      </td>

      <td>
        **replyToCommentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `ReplyClicked`
      </td>

      <td>
        **replyToCommentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `EditCommentClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `EditCommentClicked`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `CommentCreationClosePage`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `CommentCreationClosePage`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `CommentCreationContinueWriting`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `CameraIconClickedOpen`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `CameraIconClickedTakePhoto`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `CameraIconClickedChooseFromGallery`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `CameraIconClickedChooseFromGallery`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `SortByClicked`
      </td>

      <td>
        **currentSort?**: [OWSortOption](https://developers.openweb.com/docs/analytics-1#owsortoption)
      </td>
    </tr>

    <tr>
      <td>
        `SortByClosed`
      </td>

      <td>
        **currentSort?**: [OWSortOption](https://developers.openweb.com/docs/analytics-1#owsortoption)
      </td>
    </tr>

    <tr>
      <td>
        `SortByChanged`
      </td>

      <td>
        **previousSort?**: [OWSortOption](https://developers.openweb.com/docs/analytics-1#owsortoption)  
        **selectedSort?**: [OWSortOption](https://developers.openweb.com/docs/analytics-1#owsortoption)
      </td>
    </tr>

    <tr>
      <td>
        `LoadMoreComments`
      </td>

      <td>
        **paginationOffset?**: number
      </td>
    </tr>

    <tr>
      <td>
        `LoadMoreRepliesClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `HideMoreRepliesClicked`
      </td>

      <td>
        **commentId?**: string
      </td>
    </tr>

    <tr>
      <td>
        `HideMoreRepliesClicked`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `UserProfileClicked`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `MyProfileClicked`
      </td>

      <td>
        **source?**: [OWAvatarSource](https://developers.openweb.com/docs/analytics-1#x20owavatarsource)
      </td>
    </tr>

    <tr>
      <td>
        `SignUpToPostClicked`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `LoginPromptClicked`
      </td>

      <td>
        None
      </td>
    </tr>

    <tr>
      <td>
        `CommunityGuidelinesLinkClicked`
      </td>

      <td>
        None
      </td>
    </tr>
  </tbody>
</Table>

### OWSortOption

Defines the sorting order for comments in a conversation.

```typescript
export const OWSortOptionType = {
  Best: 'BEST',
  Newest: 'NEWEST',
  Oldest: 'OLDEST',
} as const;

export type OWSortOption =
  | { type: typeof OWSortOptionType.Best }
  | { type: typeof OWSortOptionType.Newest }
  | { type: typeof OWSortOptionType.Oldest };
```

### &#x20;OWAvatarSource

Identifies where a user avatar was clicked from within the app.

```typescript
export const OWAvatarSource = {
  Comment: 'comment',
  CommentCreation: 'commentCreation',
  CommentCTA: 'commentCTA',
  Notifications: 'notifications',
} as const;

export type OWAvatarSource =
  | { type: typeof OWAvatarSource.Comment }
  | { type: typeof OWAvatarSource.CommentCreation }
  | { type: typeof OWAvatarSource.CommentCTA }
  | { type: typeof OWAvatarSource.Notifications };

```