Set up Product Analytics data capture

This page instructs how to set up data capture in the context of the User Lifecycle Extension for Experience Analaytics.

  1. Initialize the Product Analytics configuration with your environment ID.

    main.dart
    import 'package:contentsquare/csq.dart';
    void main() async {
    await CSQ().configureProductAnalytics(
    environmentId: 'YOUR_ENVIRONMENT_ID',
    );
    await CSQ().start();
    }
  2. Recommended To capture screen views automatically, add the CSQNavigatorObserver to your app’s navigator observers:

    main.dart
    import 'package:contentsquare/csq.dart';
    MaterialApp(
    navigatorObservers: [
    CSQNavigatorObserver(),
    ],
    home: MyHomePage(),
    )
    More details in Track screens.
  3. Recommended In order to enable automatic capture of user interactions, add the option enableInteractionsAutocapture: true to your ProductAnalyticsOptions configuration:

    main.dart
    import 'package:contentsquare/csq.dart';
    void main() async {
    await CSQ().configureProductAnalytics(
    environmentId: 'YOUR_ENVIRONMENT_ID',
    options: ProductAnalyticsOptions(
    enableInteractionsAutocapture: true,
    ),
    );
    await CSQ().start();
    }
  4. (Optional) If your Product Analytics environment is hosted in the EU, set the baseUrl option to https://mh.ba.contentsquare.net.

    main.dart
    import 'package:contentsquare/csq.dart';
    void main() async {
    await CSQ().configureProductAnalytics(
    environmentId: 'YOUR_ENVIRONMENT_ID',
    options: ProductAnalyticsOptions(
    baseUrl: 'https://mh.ba.contentsquare.net',
    ),
    );
    await CSQ().start();
    }
  5. Add the resumePreviousSession: true and disablePageviewAutocapture: true options to the configuration.

    main.dart
    import 'package:contentsquare/csq.dart';
    void main() async {
    await CSQ().configureProductAnalytics(
    environmentId: 'YOUR_ENVIRONMENT_ID',
    options: ProductAnalyticsOptions(
    resumePreviousSession: true,
    disablePageviewAutocapture: true,
    ),
    );
    await CSQ().start();
    }