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.
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.
Before you begin
Section titled Before you beginThis guide assumes you are using Xcode with either Swift Package Manager ↗ or CocoaPods ↗ to manage external dependencies.
Install the SDK
Section titled Install the SDK-
In your XCode project >
Package Dependencies, add this repository location:https://github.com/ContentSquare/apple-sdk.git -
Set the Dependency Rule to
Exact Version1.10.0 -
Select
Add Package -
To ensure the library can start properly, add
-ObjCas a linker flag underBuild Settings>Linking - General>Other Linker Flags
-
Add the following line to your Podfile:
Podfile pod 'ContentsquareSDK', '1.10.0' -
Build your app target
Start the SDK
Section titled Start the SDK-
Configure and start the SDK with
CSQ.start().- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
AppDelegate.swift import UIKitimport ContentsquareSDK@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate {var window: UIWindow?func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {// ...CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID")}}AppDelegate.swift import UIKitimport ContentsquareSDK@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate {var window: UIWindow?func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {// ...CSQ.start(dataSourceID: "YOUR_DATASOURCE_ID")}} -
For UIKit and SwiftUI Enable screenviews and event autocapture.
- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID",options: [.enableNativeAutocapture: true])CSQ.start(dataSourceID: "YOUR_DATASOURCE_ID",options: [.enableNativeAutocapture: true]) -
(Optional) If your Product Analytics environment is hosted in the EU, set the
baseURLoption to"https://mh.ba.contentsquare.net".- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID",options: [.baseURL: "https://mh.ba.contentsquare.net"])CSQ.start(dataSourceID: "YOUR_DATASOURCE_ID",options: [.baseURL: "https://mh.ba.contentsquare.net"]) -
Implement the
optIn()API to forward user consent to the SDK, generate a user ID, and initiate tracking.- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
import UIKitimport 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}import UIKitimport 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.
-
Start your application, and check logs for this output:
[INFO] CSQ 1.10.0 for Product Analytics is attempting to start.
Next steps
Section titled Next stepsOur 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.