Enable and Use Analytics on Android

Enable analytics in your mobile app using MarketingCloudConfig.Builder() to set the necessary parameters for tracking push notifications, inbox messages, and Einstein Recommendations events.

  • To implement analytics in your mobile app, set the analyticsEnabled parameter to true.
  • To implement web and mobile analytics in your mobile app via Einstein Recommendations, set the piAnalyticsEnabled parameter to true.

Configure the SDK with analytics enabled during initialization.

For SDK version 10 or higher, use this example.

1SFMCSdk.configure(applicationContext as Application, SFMCSdkModuleConfig.build {
2  engagementModuleConfig = MarketingCloudConfig.builder().apply {
3    // Other configuration values
4    setAnalyticsEnabled(true) // Enable ET Analytics, default = false
5    setPiAnalyticsEnabled(true) // Enable Predictive Intelligence Analytics, default = false
6
7    /*
8      To explicitly control PI analytic attribution set setUseLegacyPiIdentifier to false
9      and set a value for the Predictive Intelligence Identifier in the SDK's AnalyticsManager.
10    */
11    setUseLegacyPiIdentifier(false)
12  }.build(applicationContext)
13}) {
14  // Handle initialization status
15}

For SDK version 8 or 9, use this example.

1SFMCSdk.configure(applicationContext as Application, SFMCSdkModuleConfig.build {
2  pushModuleConfig = MarketingCloudConfig.builder().apply {
3    // Other configuration values
4    setAnalyticsEnabled(true) // Enable ET Analytics, default = false
5    setPiAnalyticsEnabled(true) // Enable Predictive Intelligence Analytics, default = false
6
7    /*
8      To explicitly control PI analytic attribution set setUseLegacyPiIdentifier to false
9      and set a value for the Predictive Intelligence Identifier in the SDK's AnalyticsManager.
10    */
11    setUseLegacyPiIdentifier(false)
12  }.build(applicationContext)
13}) {
14  // Handle initialization status
15}

For SDK version 7, use this example.

1MarketingCloudSdk.init(applicationContext as Application, MarketingCloudConfig.builder().apply {
2  // Other configuration values
3  setAnalyticsEnabled(true) // Enable ET Analytics, default = false
4  setPiAnalyticsEnabled(true) // Enable Predictive Intelligence Analytics, default = false
5
6  /*
7     To explicitly control PI analytic attribution setUseLegacyPiIdentifier to false
8     and set a value for the Predictive Intelligence Identifier in the SDK's AnalyticsManager.
9   */
10  setUseLegacyPiIdentifier(false)
11
12}.build(applicationContext)) {
13  // Handle initialization status
14}

Integrate Einstein Recommendations and Collect API 

Integrate Einstein Recommendations to attribute collected analytics to specific users and track cart contents, conversions, page views, and inbox message opens. Configure the PIID identifier and use the integration methods to connect your mobile app with Einstein Recommendations.