---
title: Set up Product Analytics data capture - iOS
description: Access to acquisition analysis and lifetime metrics by implementing the Product Analytics data capture using the CSQ SDK
lastUpdated: 12 February 2026
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-ios/experience-analytics/set-up-product-analytics-data-capture/
  md: https://docs.contentsquare.com/en/csq-sdk-ios/experience-analytics/set-up-product-analytics-data-capture/index.md
---

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.

   Find your environment ID

   `YOUR_ENVIRONMENT_ID` is either provided to you by Contentsquare or you can find it in **Account** > **Manage** > **Projects** > \[Select your project] > **Environments** within the [Product Analytics web app ↗](https://heapanalytics.com/app/).

   * Swift

     ```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"
         )
       }
     }
     ```

   * Objective-C

     ```objc
     #import <UIKit/UIKit.h>
     #import <ContentsquareSDK/ContentsquareSDK.h>


     @interface AppDelegate : UIResponder <UIApplicationDelegate>


     @property (strong, nonatomic) UIWindow *window;


     @end


     @implementation AppDelegate


     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         // ...


         [CSQ configureProductAnalyticsWithEnvironmentID:@"YOUR_ENVIRONMENT_ID"];


         return YES;
     }


     @end
     ```

2. Enable autocapture with `.enableUIKitAutocapture = true`.

   * Swift

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

   * Objective-C

     ```objc
     #import <UIKit/UIKit.h>
     #import <ContentsquareSDK/ContentsquareSDK.h>


     @interface AppDelegate : UIResponder <UIApplicationDelegate>


     @property (strong, nonatomic) UIWindow *window;


     @end


     @implementation AppDelegate


     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         // ...


         NSDictionary *options = @{
             @"enableUIKitAutocapture": @YES
         };
         [CSQ configureProductAnalyticsWithEnvironmentID:@"YOUR_ENVIRONMENT_ID"
                                         additionalOptions:options];


         return YES;
     }


     @end
     ```

3. (Optional) If your Product Analytics environment is hosted in the EU, set the `baseURL` option to `https://mh.ba.contentsquare.net`.

   * Swift

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

   * Objective-C

     ```objc
     #import <UIKit/UIKit.h>
     #import <ContentsquareSDK/ContentsquareSDK.h>


     @interface AppDelegate : UIResponder <UIApplicationDelegate>


     @property (strong, nonatomic) UIWindow *window;


     @end


     @implementation AppDelegate


     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         // ...


         NSDictionary *options = @{
             @"enableUIKitAutocapture": @YES,
             @"baseUrl": @"https://mh.ba.contentsquare.net"
         };
         [CSQ configureProductAnalyticsWithEnvironmentID:@"YOUR_ENVIRONMENT_ID"
                                         additionalOptions:options];


         return YES;
     }


     @end
     ```

4. Add `.resumePreviousSession = true` and `.disablePageviewAutocapture = true`.

   * Swift

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

   * Objective-C

     ```objc
     #import <UIKit/UIKit.h>
     #import <ContentsquareSDK/ContentsquareSDK.h>


     @interface AppDelegate : UIResponder <UIApplicationDelegate>


     @property (strong, nonatomic) UIWindow *window;


     @end


     @implementation AppDelegate


     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         // ...


         NSDictionary *options = @{
             @"enableUIKitAutocapture": @YES,
             @"resumePreviousSession": @YES,
             @"disablePageviewAutocapture": @YES
         };
         [CSQ configureProductAnalyticsWithEnvironmentID:@"YOUR_ENVIRONMENT_ID"
                                         additionalOptions:options];


         return YES;
     }


     @end
     ```

Note

After adding Product Analytics to your implementation, you may observe a change in the number of sessions collected due to a change of the session timeout definition:

* (previously) Session would timeout 30 minutes after app is in background
* (now) Session would timeout 30 minutes after last event

This is part of our strategy to have a behavior that is more aligned with market standards and web definition.
