Set up product analytics data capture
Prerequisites:
- You have installed Experience Analytics.
-
Initialize the Product Analytics configuration with 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.configureProductAnalytics(environmentID: "YOUR_ENVIRONMENT_ID")}}AppDelegate.m #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 -
Enable autocapture with
.enableUIKitAutocapture = true
.AppDelegate.swift import UIKitimport ContentsquareSDK@UIApplicationMainclass 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])}}AppDelegate.m #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 -
(Optional) If your Product Analytics environment is hosted in the EU, set the
baseUrl
option tohttps://mh.ba.contentsquare.net
.AppDelegate.swift import UIKitimport ContentsquareSDK@UIApplicationMainclass 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"])}}AppDelegate.m #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 -
Add
.resumePreviousSession = true
and.disablePageviewAutocapture = true
.AppDelegate.swift import UIKitimport ContentsquareSDK@UIApplicationMainclass 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])}}AppDelegate.m #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