> For the complete documentation index, see [llms.txt](https://lionstudios.gitbook.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lionstudios.gitbook.io/readme/features/growthbook.md).

# Feature Flags

### Setup

1. Open the **Lion Settings** window and select **GrowthBook** from the left panel.
2. Ensure that **Enable Initialization** is checked.
3. **Three-Letter Game Code:** If you do not have one, please request it from your studio manager.
4. **Client Key:** If you do not have a client key, please request it from your studio manager.

<figure><img src="/files/FL5zO8ITIm38r2AW8Ipy" alt="Growthbook Settings"><figcaption><p>GrowthBook Settings - Lion Settings Window</p></figcaption></figure>

***

### **Getting Started**

#### Get Feature

Use the `GetFeature` async function to fetch a feature flag by key.

```csharp
var feature = await FeatureFlagController.GetFeature("example_key", false);
```

This returns a single feature from the local dictionary.

* If the value is already cached, it returns immediately unless you set force to true.
* Returns null if the service has not initialized successfully or if the key does not exist.

#### **Callback**

Subscribe to `OnFeatureFlagsUpdated` to be notified when feature flags are loaded or refreshed.

{% hint style="warning" %}
This callback may fire twice on startup: once when cached values are available, and again after the latest values are fetched from the server.
{% endhint %}

```csharp
FeatureFlagController.OnFeatureFlagsUpdated += FeatureFlagUpdated;
```

The callback provides the full set of feature flags in a dictionary, so you can look up keys as needed.

```csharp
private static void FeatureFlagUpdated(FeatureFlagData data, bool isLocal)
{
    data.Features.TryGetValue("feature_flag_key", out var settings)
}
```

`isLocal` will be `true` if its from the cache and `false` if its from the server

***

### Feature Flag Class <a href="#feature-flag-class" id="feature-flag-class"></a>

This class represents the data stored for a single feature flag. It contains two primary fields:

**ExperimentInfo**

Populated automatically by GrowthBook. We use this with Lion Analytics to track experiments without additional instrumentation.

* IsInExperiment *(bool)*: true if the player is assigned to an experiment bucket
* ExperimentName *(string)*: The experiment name the player is in
* VariantName *(string)*: The variant the player has been assigned

**RawString**

The raw string value returned from the server. You can parse this into their own data model as needed.

***

#### Attributes <a href="#attributes" id="attributes"></a>

The GrowthBook SDK uses the [WhoAmI service](https://docs.lionstudios.cc/readme/features/whoami-service) to automatically collect basic user attributes. These attributes are sent to our server so each player can be evaluated and bucketed immediately.

You can use attributes to segment players into specific groups:

* **Id**: Unique player identifier (used for sticky bucketing)
* **Country**: Player’s current country
* **Version**: Installed game version
* **Platform**: iOS or Android

**Attribution**

* **Network:** Acquisition network the player installed from
* **Campaign:** Acquisition campaign the player installed from

{% hint style="warning" %}
If you wish to use attribution targeting on iOS please contact your Studio Manager about enabling this feature.
{% endhint %}

Check out the example [here](/readme/features/growthbook/segmentation-example.md).


---

# 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://lionstudios.gitbook.io/readme/features/growthbook.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.
