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.
-
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();} -
Recommended To capture screen views automatically, add the
CSQNavigatorObserverto your app’s navigator observers:More details in Track screens.main.dart import 'package:contentsquare/csq.dart';MaterialApp(navigatorObservers: [CSQNavigatorObserver(),],home: MyHomePage(),) -
Recommended In order to enable automatic capture of user interactions, add the option
enableInteractionsAutocapture: trueto yourProductAnalyticsOptionsconfiguration:main.dart import 'package:contentsquare/csq.dart';void main() async {await CSQ().configureProductAnalytics(environmentId: 'YOUR_ENVIRONMENT_ID',options: ProductAnalyticsOptions(enableInteractionsAutocapture: true,),);await CSQ().start();} -
(Optional) If your Product Analytics environment is hosted in the EU, set the
baseUrloption tohttps://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();} -
Add the
resumePreviousSession: trueanddisablePageviewAutocapture: trueoptions 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();}