For the complete documentation index, see llms.txt.

Product Analytics data capture

Last updated View as MarkdownSet up with AI

Start the SDK and turn on autocapture so a single integration captures both Product Analytics and Experience Analytics data.

  1. Initialize the CSQ SDK with your environment ID.

    main.dart
    import 'package:contentsquare/csq.dart';
    void main() async {
    await CSQ().start(
    startConfig: StartConfig.withEnvironmentId(
    id: 'YOUR_ENVIRONMENT_ID',
    ),
    );
    }
  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 To enable automatic capture of user interactions, add the option enableInteractionsAutocapture: true to your AnalyticsOptions configuration:

    main.dart
    import 'package:contentsquare/csq.dart';
    void main() async {
    await CSQ().start(
    startConfig: StartConfig.withEnvironmentId(
    id: 'YOUR_ENVIRONMENT_ID',
    options: AnalyticsOptions(
    enableInteractionsAutocapture: true,
    ),
    ),
    );
    }
  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().start(
    startConfig: StartConfig.withEnvironmentId(
    id: 'YOUR_ENVIRONMENT_ID',
    options: AnalyticsOptions(
    baseUrl: Uri.parse('https://mh.ba.contentsquare.net'),
    ),
    ),
    );
    }
  5. Add the disablePageviewAutocapture: true option to the configuration.

    main.dart
    import 'package:contentsquare/csq.dart';
    void main() async {
    await CSQ().start(
    startConfig: StartConfig.withEnvironmentId(
    id: 'YOUR_ENVIRONMENT_ID',
    options: AnalyticsOptions(
    disablePageviewAutocapture: true,
    ),
    ),
    );
    }