# 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](/server-side/sdks/js-sdk/js-reference.md#hit-tracking)                   |
| [React-JS](/server-side/sdks/react/react-js-reference.md#hit-tracking)                |
| [React-Native](/server-side/sdks/react-native/react-native-reference.md#hit-tracking) |
| [PHP](/server-side/sdks/php/php-reference.md#hit-tracking)                            |
| [.NET](/server-side/sdks/net/net-reference.md#hit-tracking)                           |


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
