> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kameleoon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to collect data

> Troubleshoot missing data collection in Kameleoon feature flags and experiments with a back office and SDK-side checklist.

***

## In the back office

Ensure the following conditions are met:

* The **rule** is created for the correct **environment** (`production`, `staging`, or `development`).
* The **rule** is **enabled** (turned **on**).
* The **rule** targets **traffic** that can actually be exposed (i.e. matching segments or visitors).

***

## In the SDK

Check these points carefully:

* The `KameleoonClient` is created with the **correct configuration**:

  * `siteCode`
  * `environment` variable
  * `networkDomain` (if applicable)

* `getVisitorCode()` is called **only once**, and its value is **reused** wherever the `visitorCode` is needed.

* If using **Hybrid Mode** (with `engine.js` on the frontend):

  * The `visitorCode` is correctly **synced** between the SDK and the frontend.

* For **Experiment Rules**:

  * `setLegalConsent(true)` is called to ensure that **data collection** is allowed.

* For **Delivery Rules**:

  * `isFeatureFlagActive()` or `getVariation()` is called.
  * The method returns `true` (or the expected variation).

* For **Experiment Rules**:

  * `getVariation()` is called and returns the **expected variation**.

***

## Debugging tips

If you’ve confirmed all of the above and data is still missing:

* **Log in the console**:

  * The consent value
  * The `visitorCode`
  * The variation values. Verify that the values match those shown in the browser.

* **Enable SDK logging** and check for any **errors**.

## FAQ

> [accordion] Why are there no visits displayed on the results page?
>
> The results page might display no data for several reasons:
>
> * If you enabled bot filtering in the project settings, the SDK might set the user-agent value incorrectly. Refer to [Bot filtering](https://docs.kameleoon.com/user-manual/experiment-analytics/troubleshooting/data-discrepancies.md#how-does-kameleoon-filter-bot-traffic-from-my-results) for more details.
> * You configured Legal Consent as **Required** in the project settings, but haven't called the `setLegalConsent` SDK method. Refer to [the consent management policy](https://docs.kameleoon.com/user-manual/project-management/consent-management-policy.md#for-a/b-tests-and-feature-experiments) for more details.
> * You didn't use any of the SDK methods that send a tracking request to Kameleoon servers.
>
> For more debugging help, see [Analyze a feature flag's overall results](https://docs.kameleoon.com/user-manual/experiment-analytics/analyze-results/feature-flag-results/analyze-a-feature-flags-overall-results.md).

> [accordion] Why don't the number of visits align with my actual traffic?
>
> If you see a large number of visits from visitors, they could be bots. To prevent bots from affecting your experiment, enable the [Bot filtering option](https://docs.kameleoon.com/user-manual/experiment-analytics/troubleshooting/data-discrepancies.md#how-does-kameleoon-filter-bot-traffic-from-my-results) in your project settings. To indicate that a visitor isn't a bot, you need to pass the Kameleoon UserAgent data by using the SDK method. Calling the method prevents Kameleoon from filtering the user.

> [accordion] Why is the visitor allocation in my reports incorrect?
>
> If your reports show unexpected allocation (for example, 10/90 instead of 50/50) or if visitors are missing, it might be due to one of the following reasons:
>
> * **Narrowing the visitor pool for specific variations:** If you first call `getVariations(onlyActive: true, track: false)`, the SDK only returns visitors assigned to active (`ON`) variations. If you then only display experiment pages and call `getVariation(track: true)` for these specific visitors, Kameleoon tracks only the `ON` variation, which results in a report that only shows one variation.
> * **Insufficient time for tracking requests:** Kameleoon sends data at a specific interval. If a visitor stays on a page with an integrated Kameleoon client for the `ON` variation, but moves to a page without it for the `OFF` variation, the client might not have enough time to send the tracking request for the `OFF` variation.
> * **Missing configuration for specific variations:** You might have omitted the `UserAgent` or `setLegalConsent` for some variations. For example, if you only provide consent on the page for the `ON` variation, Kameleoon can't track visitors in the `OFF` variation.
> * **Missing visitor data:** The SDK doesn't collect visitor data automatically; you must add it explicitly for targeting and tracking to work correctly.
>
> **Check your targeting setup**
>
> If you suspect targeting issues, follow these steps:
>
> 1. Create a non-targeting rule with 100% exposure and assign your desired variation.
> 2. Add targeting and ensure the visitor stops receiving the variation.
> 3. Add the required Kameleoon data.
>
> The visitor should receive the variation again. If this fails, try using simpler targeting conditions to isolate the issue.

> [accordion] Why isn't my experiment collecting data?
>
> Kameleoon collects data for an experiment rule only when the rule is on, targets traffic that Kameleoon can expose, and the SDK calls `setLegalConsent(true)`. If you enable legal consent, Kameleoon collects data only with visitors' consent. For the SDK configuration checks and debugging steps, see [In the SDK](#in-the-sdk) and [Debugging tips](#debugging-tips).
