> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.getunleash.io/concepts/impression-data/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getunleash.io/_mcp/server. # Impression data > Unleash can provide you with impression data about the flags in your application. Impression data contains information about a specific feature flag activation check. v4.7 Requires [SDK compatibility](/sdks#feature-compatibility-in-backend-sdks). Unleash can provide you with **impression data** about the flags in your application. Impression data contains information about a specific feature flag activation check: The client SDK will emit an **impression event** when it calls `isEnabled` or `getVariant`. Some front-end SDKs emit impression events only when a flag is enabled. > **Warning** > > **Frontend SDKs and disabled flags** > > Frontend SDKs receive only enabled flags from [Unleash Edge](/unleash-edge) or the [Frontend API](/concepts/front-end-api), so by default they don't emit impression events for disabled flags. Some frontend SDKs have a configuration option that turns on impression events for all flags; check your SDK's documentation. Impression data was designed to make it easier for you to **collect analytics data**, **perform A/B tests**, and **enrich experiments** in your applications. It contains information about the feature flag and the related [Unleash Context](/concepts/unleash-context). Impression data is **opt-in on a per-flag basis**. Unleash will not emit impression events for flags not marked as such. Once you've turned impression data on for a flag, you can start listening for impression events in your client SDK. ## Impression event data There's two types of impression events you can listen for: * [`isEnabled` events](#example-isenabled-event) * [`getVariant` events](#example-getvariant-event) The `getVariant` event contains all the information found in an `isEnabled` event in addition to extra data that's only relevant to `getVariant` calls. This table describes all the properties on the impression events: | Property name | Description | Event type | | ------------- | ----------------------------------------------------------------------------- | ------------------------ | | `eventType` | The type of the event: `isEnabled` or `getVariant` | All | | `eventId` | A globally unique id (GUID) assigned to this event. | All | | `context` | A representation of the current [Unleash Context](/concepts/unleash-context). | All | | `enabled` | Whether the flag was enabled or not at when the client made the request. | All | | `featureName` | The name of the feature flag. | All | | `variant` | The name of the active variant | `getVariant` events only | ### Example `isEnabled` event ```js { eventType: 'isEnabled', eventId: '84b41a43-5ba0-47d8-b21f-a60a319607b0', context: { sessionId: 54085233, appName: 'my-webapp', environment: 'default' }, enabled: true, featureName: 'my-feature-flag', } ``` ### Example `getVariant` event ```js { eventType: 'getVariant', eventId: '84b41a43-5ba0-47d8-b21f-a60a319607b0', context: { sessionId: 54085233, appName: 'my-webapp', environment: 'default' }, enabled: true, featureName: 'my-feature-flag', variant: 'variantA' } ``` ## Enabling impression data Impression data is strictly an **opt-in** feature and must be enabled on a **per-flag basis**. You can enable and disable it both when you create a flag and when you edit a flag. You can enable impression data via the impression data flag in the admin UI's flag creation form. You can also go via the API, using the `impressionData` option. ### Request POST [https://app.unleash-instance.example.com/api/admin/projects/\{projectId}/features](https://app.unleash-instance.example.com/api/admin/projects/\{projectId}/features) ```curl curl -X POST https://app.unleash-instance.example.com/api/admin/projects/projectId/features \ -H "Authorization: " \ -H "Content-Type: application/json" \ -d '{ "name": "disable-comments" }' ``` ```python import requests url = "https://app.unleash-instance.example.com/api/admin/projects/projectId/features" payload = { "name": "disable-comments" } headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://app.unleash-instance.example.com/api/admin/projects/projectId/features'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"name":"disable-comments"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/projects/projectId/features" payload := strings.NewReader("{\n \"name\": \"disable-comments\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://app.unleash-instance.example.com/api/admin/projects/projectId/features") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"disable-comments\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://app.unleash-instance.example.com/api/admin/projects/projectId/features") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"disable-comments\"\n}") .asString(); ``` ```php request('POST', 'https://app.unleash-instance.example.com/api/admin/projects/projectId/features', [ 'body' => '{ "name": "disable-comments" }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://app.unleash-instance.example.com/api/admin/projects/projectId/features"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"disable-comments\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = ["name": "disable-comments"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/api/admin/projects/projectId/features")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` For more detailed instructions, see [the section on enabling impression data in the how-to guide for capturing impression data](/guides/how-to-capture-impression-data). ![A feature flag creation form. At the end of the form is a heading that says "Impression data", a short paragraph that describes the feature, and a flag to opt in or out of it.](/_fern-img/5ccfda7d6d240a5c8a50ee62a4c37413f22e165737323b6026a9ca8e88296fc9.webp) ## Example setup The exact setup will vary depending on your [client SDK](/sdks). The below example configures the [Unleash Proxy client](/sdks/javascript-browser) to listen for impression events and log them to the console. If "my-feature-flag" is configured to emit impression data, then it will trigger an impression event as soon as Unleash is ready. ```js const unleash = new UnleashClient({ url: 'https://eu.unleash-hosted.com/hosted/proxy', clientKey: 'your-proxy-key', appName: 'my-webapp', }); unleash.start(); unleash.on('ready', () => { unleash.isEnabled('my-feature-flag'); }); unleash.on('impression', (event) => { // Capture the event here and pass it to internal data lake or analytics provider console.log(event); }); ``` ## Understand why a flag was enabled Unleash SDKs do not expose an evaluation reason API: `isEnabled` and `getVariant` return the result of the evaluation, but not which strategy or constraint produced it. If you need to understand why a flag evaluated the way it did, you have the following options: * Use the [Playground](/concepts/playground) to simulate a context and see detailed evaluation results, including which strategies and constraints matched. This is the best tool for debugging targeting rules. * Use impression data, as described on this page, to track that a flag was evaluated, with which context, and with what result. > Unleash can provide you with impression data about the flags in your application. Impression data contains information about a specific feature flag activation check.