For the complete documentation index, see llms.txt.

Getting Started with Product Analytics

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

Use the Contentsquare wizard or skills to set up, update, and configure iOS with your AI coding assistant.

Run the wizard in your project directory. It configures your AI coding assistant, installs the matching Contentsquare integration, and verifies the installation.

npx @contentsquare/wizard install

Supports GitHub Copilot, Cursor, and Claude Code. Requires Node.js ≥ 18 and an AI coding agent with MCP support.

Use this path when you prefer to configure your AI coding assistant yourself.

1. Add the Contentsquare skill

Section titled 1. Add the Contentsquare skill

Choose how to install the Contentsquare skill.

Add the Contentsquare marketplace, then install the plugin for iOS:

Terminal window
copilot plugin marketplace add ContentSquare/agents
copilot plugin install contentsquare-ios@contentsquare

2. Ask your AI coding assistant

Section titled 2. Ask your AI coding assistant

After installing the skill, paste this prompt into your AI coding assistant:

Install Contentsquare for iOS.

Prefer to set things up manually? Continue with the steps below.

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.

This guide assumes you are using Xcode with Swift Package Manager to manage external dependencies.

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

    https://github.com/ContentSquare/apple-sdk.git
  2. Set the Dependency Rule to Exact Version 1.12.3

  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

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

    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.start(
    environmentID: "YOUR_ENVIRONMENT_ID"
    )
    }
    }
  2. For UIKit and SwiftUI Enable screenviews and event autocapture.

    CSQ.start(
    environmentID: "YOUR_ENVIRONMENT_ID",
    options: [
    .enableNativeAutocapture: true
    ]
    )
  3. (Optional) If your Product Analytics environment is hosted in the EU, set the baseURL option to "https://mh.ba.contentsquare.net".

    CSQ.start(
    environmentID: "YOUR_ENVIRONMENT_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.

    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
    }

    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:

    [INFO] CSQ 1.12.3 for Product Analytics is attempting to start.

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

Session Replay and Error Monitoring are both available with the Experience Analytics extension, which you can purchase separately.