---
title: Getting Started with Experience Analytics - iOS
description: Integrate the CSQ SDK for Experience Analytics into your iOS app in minutes
lastUpdated: 07 April 2026
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-ios/experience-analytics/
  md: https://docs.contentsquare.com/en/csq-sdk-ios/experience-analytics/index.md
---

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

This quick start guide shows you how to get Contentsquare Experience Analytics set up in an iOS application.

After completing the setup process, you'll be able to take full advantage of the CSQ API to collect data from your app, within just a few minutes.

Upgrading

See our guide to upgrade to the CSQ SDK from the [CS SDK](upgrade-from-cs-sdk/).

## Before you begin

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

## Install the SDK

* Swift Package Manager

  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.6.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`.

* Cocoapods

  1. Add the following line to your Podfile:

     **Podfile**

     ```diff
     pod 'ContentsquareSDK', '1.6.3'
     ```

  2. Build your app target.

## Start the SDK

1. Import the `ContentsquareSDK` module in `AppDelegate`:

   * Swift

     **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 {
         ...
       }
     }
     ```

   * Objective-C

     **AppDelegate.m**

     ```objective-c
     #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 {
         ...
     }


     @end
     ```

2. Add a call to `CSQ.start()`:

   * Swift

     **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()
         return true
       }


     }
     ```

   * Objective-C

     **AppDelegate.m**

     ```objective-c
     #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 start];
         return YES;
     }


     @end
     ```

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

   ```text
   [INFO] CSQ v1.6.3 is starting Digital eXperience Analytics.
   ```

## Get user consent

The CSQ SDK treats users as opted-out by default.

Implement the [`optIn()`](command-reference/#csqoptin) API to forward user consent to the SDK and generate a user ID.

* Swift

  ```swift
  import UIKit
  import ContentsquareSDK


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


  @objc func optInButtonTapped(_ sender: UIButton) {
      CSQ.start()
      CSQ.optIn()
      ...
  }
  ```

* Objective-C

  ```objective-c
  #import <UIKit/UIKit.h>
  #import <ContentsquareSDK/ContentsquareSDK.h>
  [optinButton addTarget:self action:@selector(optInButtonTapped:) forControlEvents:UIControlEventTouchUpInside];


  - (void)optInButtonTapped:(UIButton *)sender {
      [CSQ start];
      [CSQ optIn];
      // Additional initialization or navigation code...
  }
  ```

## Track your first screens

Contentsquare aggregates the user behavior and engagement at the screen level. Start your SDK implementation by tracking key screens like the home screen, product list, product details, or conversion funnel.

Once tracking has started, you're able to take full advantage of the CSQ SDK API to track screen views, monitor user interactions, and capture app behavior data.

Contentsquare Experience Analytics also comes with powerful Session Replay and Error Monitoring capabilities as paid options.

### Sending screenview events

Screen tracking is achieved by sending a `screenview` event:

* Right after the SDK has started
* When the screen appears
* When a modal/pop-up is closed and the user is back on the screen
* When the app is put in the foreground (after an app hide)

As a general rule of thumb, you should send your screenviews in `viewWillAppear(_ animate: Bool)` when using UIKit, in `.onAppear()` when using SwiftUI.

* Swift

  ```swift
  import ContentsquareSDK


  CSQ.trackScreenview(String, cvars: [CustomVar] = [])
  ```

* Objective-C

  ```objective-c
  #import <ContentsquareSDK/ContentsquareSDK.h>


  [CSQ trackScreenview:(NSString * _Nonnull)];
  // or
  [CSQ trackScreenview:(NSString * _Nonnull) cvars:(NSArray<CustomVar *> * _Nonnull)]; // To add custom variables to screen tracking
  ```

For more information see [Implementation recommendations](track-screens/#implementation-recommendations)

## Next Steps

While screen tracking gives an overview of user navigation, capturing session, screen, or user metadata provides a deeper understanding of the context behind user behavior.

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

Proceed with these how-to's to refine your implementation.

[Custom Variables ](track-custom-variables/)Collect additional details about the screen or the user.

[Dynamic Variables ](track-dynamic-variables/)Collect additional information about the session.

[Transactions tracking ](track-transactions/)Associate user's session with their potential purchases and corresponding revenue.

[WebViews ](track-webviews/)For native apps which embark web applications or pages.

[Session Replay ](session-replay/)Collect data for Session Replay in compliance personal data masking.

[Error Analysis ](error-analysis/)Track API errors and application crashes with automated collection and privacy-safe debugging tools.
