1. Record Activation Event

You can call the  - trackAppInstallWithProperties:  method to record an activation event. Calling this method multiple times will only trigger the activation event on the first call:

#error 如果您之前使用 - trackInstallation:  触发的激活事件,需要继续保持原来的调用,无需改为 - trackAppInstall: , 否则会导致激活事件数据分离。 [[SensorsAnalyticsSDK sharedInstance] trackAppInstallWithProperties:@{@"DownloadChannel": @"AppStore"}];
CODE
#error 如果您之前使用 - trackInstallation:  触发的激活事件,需要继续保持原来的调用,无需改为 - trackAppInstall: , 否则会导致激活事件数据分离。 SensorsAnalyticsSDK.sharedInstance()?.trackAppInstall(withProperties: ["DownloadChannel": "AppStore"])
CODE

If the original activation event name is not $AppInstall, this parameter is required复制从 .虚拟事件(新) v2.5Combine the original activation event and $AppInstall to analyze the data, and consult technical support for details.

1.1. Use IDFA for accurate channel tracking

This feature requires adding the NSUserTrackingUsageDescription configuration to the info.plist file.

- (void)applicationDidBecomeActive:(UIApplication *)application{ // 需要 #import <AppTrackingTransparency/AppTrackingTransparency.h> if (@available(iOS 14, *)) { [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { // iOS 14 及以上记录激活事件。 #error 如果您之前使用 - trackInstallation:  触发的激活事件,需要继续保持原来的调用,无需改为 - trackAppInstall: , 否则会导致激活事件数据分离。 [[SensorsAnalyticsSDK sharedInstance] trackAppInstallWithProperties:@{@"DownloadChannel": @"AppStore"}]; }]; } else { // iOS 13 及以下记录激活事件 #error 激活接口请与上面接口保持一致 [[SensorsAnalyticsSDK sharedInstance] trackAppInstallWithProperties:@{@"DownloadChannel": @"AppStore"}]; } }
CODE
func applicationDidBecomeActive(_ application: UIApplication) { if #available(iOS 14, *) { ATTrackingManager.requestTrackingAuthorization { (status) in // iOS 14 及以上记录激活事件。 				 #error 如果您之前使用 - trackInstallation:  触发的激活事件,需要继续保持原来的调用,无需改为 - trackAppInstall: , 否则会导致激活事件数据分离。 SensorsAnalyticsSDK.sharedInstance()?.trackAppInstall(withProperties: ["DownloadChannel": "AppStore"]) } } else { // iOS 13 及以下记录激活事件 		 		 #error 激活接口请与上面接口保持一致 SensorsAnalyticsSDK.sharedInstance()?.trackAppInstall(withProperties: ["DownloadChannel": "AppStore"]) } }
CODE
IDFA authorization code needs to be executed when the UIApplicationStateis in Active state. For more information, please refer to the Apple Developer Center.

For more information about the channel tracking feature, please refer to the Channel Track.

2. Track, match and return channels

Starting from iOS v2.0.9, the SDK supports adding channel properties to custom events triggered by the track method. Set the enableAutoAddChannelCallbackEvent property of the SAConfigOptions instance to YES before initialization to support adding channel properties to custom events.

SAConfigOptions *options = [[SAConfigOptions alloc] initWithServerURL:SA_SERVER_URL launchOptions:launchOptions]; // 自定义埋点事件中自动添加渠道匹配信息 options.enableAutoAddChannelCallbackEvent = YES; [SensorsAnalyticsSDK startWithConfigOptions:options];
CODE
let options = SAConfigOptions.init(serverURL: SA_SERVER_URL, launchOptions: launchOptions) // 自定义埋点事件中自动添加渠道匹配信息 options.enableAutoAddChannelCallbackEvent = true SensorsAnalyticsSDK.start(configOptions: options)
CODE
  • Record events and perform channel matching and return for the current installation and first trigger.
  • Contemporaneous installationretrigger return event, record event, but does not carry out channel matching and return.
  • Unloading and reloadingfirst trigger return event, record event, and channel matching and return.

p.s. The above rules apply to events with the same name, and different events do not affect each other.


3. Advertising-related Event Reporting

Starting from iOS SDK v4.5.19, it supports reporting advertising-related events directly to the advertising server. The specific usage is as follows:

SAConfigOptions *options = [[SAConfigOptions alloc] initWithServerURL:SA_SERVER_URL launchOptions:launchOptions]; //初始化一个密钥,需要提供密钥、密钥的版本、以及对称和非对称加密的类型 SASecretKey *key = [[SASecretKey alloc] initWithKey:@"key" version:11 asymmetricEncryptType:@"RSA" symmetricEncryptType:@"AES"]; //初始化广告相关配置, 需要事件上报到广告服务器的地址,哪些事件需要上报以及加密密钥 SAAdvertisingConfig *advertisingConfig = [[SAAdvertisingConfig alloc] initWithServerUrl:@"上报到广告服务器的地址" events:@[@“$AppInstall”] secretKey:key]; options.advertisingConfig = advertisingConfig; [SensorsAnalyticsSDK startWithConfigOptions:options];
CODE
  • If the event reporting to the advertising server does not require encryption, the key can be set as nil when initializing SAAdvertisingConfig.
  • When initializing SAAdvertisingConfig, the reporting address and event collection parameters are required.
  • Contact the after-sales or delivery team to obtain the reporting address and encryption key for the advertising server.


4. Advertising Remarketing

Starting from iOS SDK v4.5.23, it supports advertising remarketing. The specific usage is as follows:

SAConfigOptions *options = [[SAConfigOptions alloc] initWithServerURL:SA_SERVER_URL launchOptions:launchOptions]; //初始化广告相关配置 SAAdvertisingConfig *advertisingConfig = [[SAAdvertisingConfig alloc] init]; advertisingConfig.enableRemarketing = YES; //如果 SDK 需要延迟初始化,请记录拉起 App 时的 url,并在初始化时传入 SDK,SDK 如果非延迟初始化,无需设置此项 advertisingConfig.wakeupUrl = @"延迟初始化SDK 时唤起 app 的 url"; [SensorsAnalyticsSDK startWithConfigOptions:options];
CODE