Set up product analytics data capture

Prerequisites:

  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
    ]
    )
    }
    }