> For the complete documentation index, see [llms.txt](https://docs.contextsdk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.contextsdk.com/advanced/capturing-context-in-key-moments.md).

# Capturing Context In Key Moments

Our SDK provides event tracking APIs to capture user interactions within your app, enabling insights into usage across real-world contexts.

Logging these events is optional and for informational purposes only. It will not influence your app's behavior.

### Page Views

Track when users navigate between different screens. This data helps you understand which screens users interact with most frequently in various real-world contexts.

{% tabs %}
{% tab title="Swift" %}

```swift
ContextManager.trackPageView("page_identifier")
```

{% endtab %}

{% tab title="Android" %}

```kotlin
ContextSDK.trackPageView("page_identifier");
```

{% endtab %}

{% tab title="Flutter" %}

```dart
_contextSdkPlugin.trackPageView("page_identifier");
```

{% endtab %}

{% tab title="Unity" %}

```csharp
ContextSDKBinding.TrackPageView("page_identifier");
```

{% endtab %}

{% tab title="React Native" %}

```javascript
import { trackPageView } from 'react-native-context-sdk';

trackPageView("page_identifier");
```

{% endtab %}
{% endtabs %}

### User Actions

Record specific user actions, such as enabling a feature, tapping buttons, creating accounts, or sharing content. Capturing these events helps you gain insights into how user interactions correlate with different real-world scenarios.

{% tabs %}
{% tab title="Swift" %}

```swift
ContextManager.trackUserAction("user_tapped_share_button")
```

{% endtab %}

{% tab title="Android" %}

```kotlin
ContextSDK.trackUserAction("user_tapped_share_button");
```

{% endtab %}

{% tab title="Flutter" %}

```dart
_contextSdkPlugin.trackUserAction("user_tapped_share_button");
```

{% endtab %}

{% tab title="Unity" %}

```csharp
ContextSDKBinding.TrackUserAction("user_tapped_share_button");
```

{% endtab %}

{% tab title="React Native" %}

```javascript
import { trackUserAction } from 'react-native-context-sdk';

trackUserAction("user_tapped_share_button");
```

{% endtab %}
{% endtabs %}

### Generic Events

Track custom events that don't fall under the other categories. Alternatively, add this to your existing analytics code to easily log all your existing events into ContextSDK, allowing us to provide you insights without much effort.

{% tabs %}
{% tab title="Swift" %}

```swift
ContextManager.trackEvent("custom_event")
```

{% endtab %}

{% tab title="Android" %}

```kotlin
ContextSDK.trackEvent("custom_event");
```

{% endtab %}

{% tab title="Flutter" %}

```dart
_contextSdkPlugin.trackEvent("custom_event");
```

{% endtab %}

{% tab title="Unity" %}

```csharp
ContextSDKBinding.TrackEvent("custom_event");
```

{% endtab %}

{% tab title="React Native" %}

```javascript
import { trackEvent } from 'react-native-context-sdk';

trackEvent("custom_event");
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.contextsdk.com/advanced/capturing-context-in-key-moments.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
