> For the complete documentation index, see [llms.txt](https://docs.abtasty.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.abtasty.com/server-side/sdks/key-features/tracking-data.md).

# Tracking Data

In the `Flagship SDK`, a Hit is a user interaction with your application that is tracked and sent to the Flagship server whenever a user performs a specific action or reaches a certain point in your application.

The SDK does not directly send hits as they are emitted. It uses the tracking manager, which is a mechanism that sends them to Flagship by batch through HTTPS. The tracking manager's batch processing reduces network traffic, prevents hits loss through caching, and resends any failed hits.

There are five different types of Hits, each corresponding to a specific KPI: `Page`, `Screen`, `Transaction]`, `Item`, and `Event`. For additional details, refer to your specific SDK reference documentation.

The `sendHit` method of the **visitor instance** is used to send these hits to the Flagship server.

Below are examples in different programming environments:

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

```javascript
import { HitType, EventCategory } from "@flagship.io/js-sdk";

// ... other code

visitor.sendHit({
  type: HitType.EVENT, 
  category: EventCategory.USER_ENGAGEMENT,
  action: "click",
  label: "label",
  value: 100,
});
```

{% endtab %}

{% tab title="React" %}

```jsx
import React from "react";
import { FlagshipProvider, useFlagship, HitType, EventCategory } from "@flagship.io/react-sdk";

const App = () => (
  <>
    <FlagshipProvider
      envId="<ENV_ID>"
      apiKey="<API_KEY>"
      visitorData={{
        id: "<VISITOR_ID>",
        hasConsented: true, 
          context: {
            isVIP: true,
          }
      }}
    >
      <Component/>
    </FlagshipProvider>
  </>
);

const Component = () => {
  const { sendHit } = useFlagship();
  
  return (
    <div>
      <h1>My component</h1>
      <button onClick={() =>{
          sendHit({
            type: HitType.EVENT,
            category: EventCategory.USER_ENGAGEMENT,
            action: "click",
            label: "label",
            value: 100,
          });
        }}>
        Send event</button>
    </div>
  );
};
```

{% endtab %}

{% tab title="React native" %}

```jsx
import React from "react";
import { FlagshipProvider, useFlagship, HitType, EventCategory } from "@flagship.io/react-native-sdk";

const App = () => (
  <>
    <FlagshipProvider
      envId="<ENV_ID>"
      apiKey="<API_KEY>"
      visitorData={{
        id: "<VISITOR_ID>",
        hasConsented: true, 
          context: {
            isVIP: true,
          }
      }}
    >
      <Component/>
    </FlagshipProvider>
  </>
);

const Component = () => {
  const { sendHit } = useFlagship();
  
  return (
    <div>
      <h1>My component</h1>
      <button onClick={() =>{
          sendHit({
            type: HitType.EVENT,
            category: EventCategory.USER_ENGAGEMENT,
            action: "click",
            label: "label",
            value: 100,
          });
        }}>
        Send event</button>
    </div>
  );
};
```

{% endtab %}

{% tab title="PHP" %}

```php
use Flagship\Enum\EventCategory;

// ... other code

$event = new Event(EventCategory::ACTION_TRACKING, "click");
$event->setLabel("label")->setValue(100);

$visitor->sendHit($event);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using Flagship.Hit;

// ... other code

var eventHit = new Event(EventCategory.ACTION_TRACKING, "click")
{
  Label = "label",
  Value = 100=
};

_ = visitor.SendHit(eventHit);
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
📘 Information

When a visitor **sets consent to false**, the data collection features (**visitorExposed** and **Track data**) will be deactivated for them. All hits related to the visitor will be flushed from the pool and the cache.
{% endhint %}

Please consult the reference documentation for your specific SDK for more detailed information:

| SDK                                                                                                           |
| ------------------------------------------------------------------------------------------------------------- |
| [Javascript](https://docs.abtasty.com/server-side/sdks/js-sdk/js-reference.md#hit-tracking)                   |
| [React-JS](https://docs.abtasty.com/server-side/sdks/react/react-js-reference.md#hit-tracking)                |
| [React-Native](https://docs.abtasty.com/server-side/sdks/react-native/react-native-reference.md#hit-tracking) |
| [PHP](https://docs.abtasty.com/server-side/sdks/php/php-reference.md#hit-tracking)                            |
| [.NET](https://docs.abtasty.com/server-side/sdks/net/net-reference.md#hit-tracking)                           |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.abtasty.com/server-side/sdks/key-features/tracking-data.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
