---
title: Getting Started with Product Analytics - iOS
description: Integrate the CSQ SDK for Product Analytics into your iOS app with step-by-step instructions for installation and configuration
lastUpdated: 08 July 2026
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-ios/product-analytics/
  md: https://docs.contentsquare.com/en/csq-sdk-ios/product-analytics/index.md
---

> Documentation index: https://docs.contentsquare.com/llms.txt
> Use this file to discover all available pages before exploring further.

Use this quick start guide to set up a new instance of Contentsquare's Product Analytics SDK in an iOS application.

Faster implementation using agent skills

Use [Agent skills](https://docs.contentsquare.com/csq-sdk-ios/product-analytics/using-agent-skills/) to let your AI coding assistant handle SDK setup, version migration, and feature implementation automatically.

Once you've completed the setup process, the Contentsquare SDK will capture a wide variety of user interactions in your application with no additional code required.

Upgrading

See our guides to upgrade to the CSQ SDK from the [Heap Core SDK](../product-analytics/upgrade-from-heap-core-sdk/) or the [Heap Classic SDK](../product-analytics/upgrade-from-heap-classic-sdk/).

## Before you begin

This guide assumes you are using Xcode with [Swift Package Manager ↗](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app) to manage external dependencies.

## Install the SDK

CocoaPods support is ending

CocoaPods trunk becomes read-only on December 2, 2026. After this date, Contentsquare will no longer publish new SDK versions via CocoaPods. [Migrate to Swift Package Manager (SPM)](https://docs.contentsquare.com/en/csq-sdk-ios/migrate-from-cocoapods/) to continue receiving updates.

1. In your Xcode project > `Package Dependencies`, add this repository location:

   ```plaintext
   https://github.com/ContentSquare/apple-sdk.git
   ```

2. Set the Dependency Rule to `Exact Version` `1.10.0`

3. Select `Add Package`

4. To ensure the library can start properly, add `-ObjC` as a linker flag under `Build Settings` > `Linking - General` > `Other Linker Flags`

## Start the SDK

1. Configure and start the SDK with `CSQ.start()`.

   * Product Analytics

     **AppDelegate.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.start(
           environmentID: "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/).

   * CSQ Experience Platform (Early Access)

     **AppDelegate.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.start(
           dataSourceID: "YOUR_DATASOURCE_ID"
         )
       }
     }
     ```

     Find your data source ID

     `YOUR_DATASOURCE_ID` is either provided to you by Contentsquare or you can find it in **Definitions** > **Data sources** > \[Expand your mobile data source] > \[Copy the App ID in step 1] within the [CSQ Experience Platform web app ↗](https://app.contentsquare.com/).

2. For UIKit and SwiftUI Enable screenviews and event autocapture.

   * Product Analytics

     ```swift
     CSQ.start(
       environmentID: "YOUR_ENVIRONMENT_ID",
       options: [
         .enableNativeAutocapture: true
       ]
     )
     ```

   * CSQ Experience Platform (Early Access)

     ```swift
     CSQ.start(
       dataSourceID: "YOUR_DATASOURCE_ID",
       options: [
         .enableNativeAutocapture: true
       ]
     )
     ```

   Note

   [Customize screen names](../product-analytics/customize-autocaptured-screen-names/) to better match your analysis needs.

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

   * Product Analytics

     ```swift
     CSQ.start(
       environmentID: "YOUR_ENVIRONMENT_ID",
       options: [
         .baseURL: "https://mh.ba.contentsquare.net"
       ]
     )
     ```

   * CSQ Experience Platform (Early Access)

     ```swift
     CSQ.start(
       dataSourceID: "YOUR_DATASOURCE_ID",
       options: [
         .baseURL: "https://mh.ba.contentsquare.net"
       ]
     )
     ```

4. Implement the `optIn()` API to forward user consent to the SDK, generate a user ID, and initiate tracking.

   * Product Analytics

     ```swift
     import UIKit
     import ContentsquareSDK


     // In viewDidLoad()
     optinButton.addTarget(self, action: #selector(optInButtonTapped), for: .touchUpInside)


     @objc func optInButtonTapped(_ sender: UIButton) {
       CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID")
       CSQ.optIn()
       // Continue with post-consent navigation or UI update
     }
     ```

   * CSQ Experience Platform (Early Access)

     ```swift
     import UIKit
     import ContentsquareSDK


     // In viewDidLoad()
     optinButton.addTarget(self, action: #selector(optInButtonTapped), for: .touchUpInside)


     @objc func optInButtonTapped(_ sender: UIButton) {
       CSQ.start(dataSourceID: "YOUR_DATASOURCE_ID")
       CSQ.optIn()
       // Continue with post-consent navigation or UI update
     }
     ```

   Once tracking has started, you're able to take full advantage of the CSQ SDK API to identify users, track custom events, and more.

   Contentsquare's Product Analytics module will also automatically start tracking a wide range of user interactions, view controller changes, and app version changes without any additional code.

5. Start your application, and check logs for this output:

   ```text
   [INFO] CSQ 1.10.0 for Product Analytics is attempting to start.
   ```

## Next steps

Our SDK offers a wide range of features to enhance your implementation, including extended tracking capabilities, and personal data masking.

[Track identity](track-identity/) Link anonymous and identified user data across sessions and devices for comprehensive analytics

[Track push notifications](track-push-notifications/)Track mobile notification interactions automatically

[Track events manually](track-events-manually/)Learn how to track custom events

[Hide sensitive data](hide-sensitive-data/)Protect sensitive data by disabling text capture, masking specific views, or ignoring interactions

Session Replay and Error Monitoring are both available with the [Experience Analytics extension](dxae-setup/), which you can purchase separately.

[Experience Analytics extension](dxae-setup/)
