Set up Product Analytics data capture

This page instructs how to set up Product Analytics data capture in combination with Experience Analytics.

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

    AppDelegate.swift
    import UIKit
    import ContentsquareSDK
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // ...
    CSQ.configureProductAnalytics(
    environmentID: "YOUR_ENVIRONMENT_ID"
    )
    }
    }
  2. Enable autocapture with .enableUIKitAutocapture = true.

    AppDelegate.swift
    import UIKit
    import ContentsquareSDK
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // ...
    CSQ.configureProductAnalytics(
    environmentID: "YOUR_ENVIRONMENT_ID",
    additionalOptions: [
    .enableUIKitAutocapture: true
    ]
    )
    }
    }
  3. (Optional) If your Product Analytics environment is hosted in the EU, set the baseURL option to https://mh.ba.contentsquare.net.

    AppDelegate.swift
    import UIKit
    import ContentsquareSDK
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // ...
    CSQ.configureProductAnalytics(
    environmentID: "YOUR_ENVIRONMENT_ID",
    additionalOptions: [
    .enableUIKitAutocapture: true,
    .baseUrl: "https://mh.ba.contentsquare.net"
    ]
    )
    }
    }
  4. Add .resumePreviousSession = true and .disablePageviewAutocapture = true.

    AppDelegate.swift
    import UIKit
    import ContentsquareSDK
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // ...
    CSQ.configureProductAnalytics(
    environmentID: "YOUR_ENVIRONMENT_ID",
    additionalOptions: [
    .enableUIKitAutocapture: true,
    .resumePreviousSession: true,
    .disablePageviewAutocapture: true
    ]
    )
    }
    }