---
title: Getting Started with Product Analytics - Flutter
description: Integrate the CSQ SDK for Product Analytics into your Flutter app with step-by-step instructions for installation and configuration
lastUpdated: 02 June 2026
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-flutter/product-analytics/
  md: https://docs.contentsquare.com/en/csq-sdk-flutter/product-analytics/index.md
---

> Documentation index: https://docs.contentsquare.com/llms.txt
> Use this file to discover all available pages before exploring further.

Use this quick start guide to set up the CSQ Product Analytics SDK in a Flutter application.

Tip

**Integrate faster with AI skills** Beta — Use the Contentsquare AI skills to let your AI coding assistant handle SDK setup, version migration, and feature implementation automatically. [Explore AI skills](https://docs.contentsquare.com/csq-sdk-flutter/product-analytics/using-agent-skills/)

Once you've completed the setup process, the CSQ SDK will capture a wide variety of user interactions in your application with no additional code required.

Upgrading

See our guides to upgrade to the CSQ SDK

* [from the Heap Core SDK](../product-analytics/upgrade-from-heap-core-sdk/)
* [from the Heap Core SDK + Contentsquare SDK](../product-analytics/upgrade-from-heap-and-cs-sdk/)

## Install the SDK

With Flutter CLI:

```shell
flutter pub add contentsquare
```

This will add a line like this to your package's `pubspec.yaml` (and run an implicit `flutter pub get`):

**pubspec.yaml**

```yaml
dependencies:
flutter:
  sdk: flutter
contentsquare: ^4.2.2
```

## Start the SDK

1. Import the CSQ SDK in your app:

   ```dart
   import 'package:contentsquare/csq.dart';
   ```

2. Configure and start the SDK as soon as possible in your app, ideally in the `main()` function.

   Find your environment ID

   `YOUR_ENVIRONMENT_ID` is either provided to you by Contentsquare or you can find it in **Account** > **Manage** > **Projects** > \[Select your project] > **Environments** within the [Product Analytics web app ↗](https://heapanalytics.com/app/).

   * Standalone

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';


     void main() async {
       await CSQ().start(
         startConfig: StartConfig.withEnvironmentId(
           id: 'YOUR_ENVIRONMENT_ID',
         ),
       );
     }
     ```

   * CSQ Experience Platform

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';


     void main() async {
       await CSQ().start(
         startConfig: StartConfig.withDatasourceId(
           id: 'YOUR_DATASOURCE_ID',
         ),
       );
     }
     ```

3. (**Optional**) Add `AnalyticsOptions`. For example if your Product Analytics environment is hosted in the EU, set the `baseUrl` option to `https://mh.ba.contentsquare.net`

   * Standalone

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';


     void main() async {
       await CSQ().start(
         startConfig: StartConfig.withEnvironmentId(
           id: 'YOUR_ENVIRONMENT_ID',
           options: AnalyticsOptions(
             baseUrl: Uri.parse('https://mh.ba.contentsquare.net'),
           ),
         ),
       );
     }
     ```

   * CSQ Experience Platform

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';


     void main() async {
       await CSQ().start(
         startConfig: StartConfig.withDatasourceId(
           id: 'YOUR_DATASOURCE_ID',
           options: AnalyticsOptions(
             baseUrl: Uri.parse('https://mh.ba.contentsquare.net'),
           ),
         ),
       );
     }
     ```

4. Start your application, and check logs for this output:

   ```text
   ┌───────────────────────────────────────────────────────────────────────────────
   │ 🔔 IMPORTANT 🔔 (CSLIB 4.2.2)
   ├───────────────────────────────────────────────────────────────────────────────
   │ Contentsquare Flutter SDK 4.2.2 starting in app:
   │ com.example.testapp
   └───────────────────────────────────────────────────────────────────────────────
   ```

5. Recommended To capture screen views automatically, add the `CSQNavigatorObserver` to your app's navigator observers:

   **main.dart**

   ```dart
   import 'package:contentsquare/csq.dart';


   MaterialApp(
     navigatorObservers: [
       CSQNavigatorObserver(),
     ],
     home: MyHomePage(),
   )
   ```

   More details in [Customize autocaptured screens](https://docs.contentsquare.com/en/csq-sdk-flutter/product-analytics/customize-autocaptured-screens/).

6. Recommended To enable automatic capture of user interactions, add the option `enableInteractionsAutocapture: true` to your `AnalyticsOptions` configuration:

   * Standalone

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';


     void main() async {
       await CSQ().start(
         startConfig: StartConfig.withEnvironmentId(
           id: 'YOUR_ENVIRONMENT_ID',
           options: AnalyticsOptions(
             enableInteractionsAutocapture: true,
           ),
         ),
       );
     }
     ```

   * CSQ Experience Platform

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';


     void main() async {
       await CSQ().start(
         startConfig: StartConfig.withDatasourceId(
           id: 'YOUR_DATASOURCE_ID',
           options: AnalyticsOptions(
             enableInteractionsAutocapture: true,
           ),
         ),
       );
     }
     ```

## Get user consent

Implement the [`optIn()`](command-reference/#csqoptin) API to forward user consent to the SDK and generate a user ID.

The CSQ SDK treats users as opted-out by default.

It can be done immediately after `start` is called:

**main.dart**

```dart
void main() async {
  // ...
  await CSQ().start();
  await CSQ().optIn();
  // ...
}
```

Alternatively, you can call `optIn()` in response to a user action, such as tapping an "I agree" button:

```dart
class UserConsentScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('User Consent'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () async {
            await CSQ().optIn();
          },
          child: Text('Agree with Terms and Conditions'),
        ),
      ),
    );
  }
}
```

## Next steps

Our SDK offers a wide range of features to enhance your implementation, including extended tracking capabilities, and personal data masking.

[Track identity ](track-identity/)Link anonymous and identified user data across sessions and devices for comprehensive analytics

[Track push notifications ](track-push-notifications/)Track mobile notification interactions automatically

[Track events manually ](track-events-manually/)Learn how to track custom events

[Hide sensitive data ](privacy-and-sensitive-data/)Protect sensitive data by disabling text capture, masking specific views, or ignoring interactions

Session Replay and Error Monitoring are both available with the [Experience Analytics Extension](dxae-setup/), which you can purchase separately.

[Set up the Experience Analytics extension](dxae-setup/)
