-
Notifications
You must be signed in to change notification settings - Fork 0
Sending background hits 0d80a8
Identification enables you to distinguish hits sent following direct usage of your application from hits sent in the background, automatically and independently of the user, with the help of background fetch or a background task for example.
The tracker possesses a context property, which possesses a subproperty, backgroundMode. This is BackgroundMode-type enumeration.
By default, this property is set to Normal. In the case of background fetch tagging, the property must be set to Fetch, and in all other cases of tagging automatic behaviours independent of the user, it should be set to Task.
To tag these types of functioning, it is recommended to use an instance of a dedicated tracker. If you wish to use just one tracker instance, you must remember to reset the property to Normal at the end of execution of background fetch or background task.
-
Tagging background fetch with a dedicated tracker
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let tracker = ATInternet.sharedInstance.tracker("bgFetchTracker")
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionKey: Any]?) -> Bool {
tracker.context.backgroundMode = BackgroundMode.fetch
return true
}
func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// Do the work associated with the fetch
tracker.gestures.add("fetch").sendDownload()
}
}#import "SmartTracker/SmartTracker-Swift.h"
@interface AppDelegate ()
@property (nonatomic, strong) Tracker *tracker;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.tracker = [[ATInternet sharedInstance] trackerWithName:@"bgFetchTracker"];
self.tracker.context.backgroundMode = BackgroundModeFetch;
return YES;
}
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Do the work associated with the fetch
[[self.tracker.gestures add:@"fetch"] sendDownload];
}
@end-
Tagging background fetch with a global tracker
func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
// Do the work associated with the fetch
let tracker = ATInternet.sharedInstance.defaultTracker
tracker.context.backgroundMode = BackgroundMode.fetch
tracker.gestures.add("fetch").sendDownload()
tracker.context.backgroundMode = BackgroundMode.normal
}- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Do the work associated with the fetch
Tracker *tracker = [ATInternet sharedInstance].defaultTracker;
tracker.context.backgroundMode = BackgroundModeFetch;
[[tracker.gestures addWithName:@"fetch"] sendDownload];
tracker.context.backgroundMode = BackgroundModeNormal;
}-
Tagging a background task with a dedicated tracker
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let tracker = ATInternet.sharedInstance.tracker("bgTaskTracker")
var task = UIBackgroundTaskInvalid
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
tracker.context.backgroundMode = BackgroundMode.task
return true
}
func applicationDidEnterBackground(application: UIApplication) {
self.task = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler { () -> Void in
application.endBackgroundTask(self.task)
self.task = UIBackgroundTaskInvalid
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in
// Do the work associated with the task
self.tracker.gestures.add("task").sendDownload()
application.endBackgroundTask(self.task)
self.task = UIBackgroundTaskInvalid
})
}
}#import "SmartTracker/SmartTracker-Swift.h"
@interface AppDelegate ()
@property (nonatomic, strong) Tracker *tracker;
@property (nonatomic) UIBackgroundTaskIdentifier task;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.tracker = [[ATInternet sharedInstance] trackerWithName:@"bgTaskTracker"];
self.tracker.context.backgroundMode = ATBackgroundModeTask;
self.task = UIBackgroundTaskInvalid;
return YES;
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
self.task = [application beginBackgroundTaskWithName:@"MyTask" expirationHandler:^{
[application endBackgroundTask:self.task];
self.task = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work associated with the task
[[self.tracker.gestures add:@"task"] sendDownload];
[application endBackgroundTask:self.task];
self.task = UIBackgroundTaskInvalid;
});
}
@end-
Tagging a background task with a global tracker
func applicationDidEnterBackground(_ application: UIApplication) {
let tracker = ATInternet.sharedInstance.defaultTracker
tracker.context.backgroundMode = BackgroundMode.task
self.task = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler { () -> Void in
tracker.context.backgroundMode = BackgroundMode.normal
application.endBackgroundTask(self.task)
self.task = UIBackgroundTaskInvalid
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in
// Do the work associated with the task
tracker.gestures.add("task").sendDownload()
tracker.context.backgroundMode = BackgroundMode.normal
application.endBackgroundTask(self.task)
self.task = UIBackgroundTaskInvalid
})
}- (void)applicationDidEnterBackground:(UIApplication *)application {
Tracker *tracker = [ATInternet sharedInstance].defaultTracker;
tracker.context.backgroundMode = BackgroundModeTask;
self.task = [application beginBackgroundTaskWithName:@"MyTask" expirationHandler:^{
tracker.context.backgroundMode = BackgroundModeNormal;
[application endBackgroundTask:self.task];
self.task = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work associated with the task
[[tracker.gestures add:@"task"] sendDownload];
tracker.context.backgroundMode = BackgroundModeNormal;
[application endBackgroundTask:self.task];
self.task = UIBackgroundTaskInvalid;
});
}-
Data API
- Data flow
- Advice optimizations data flow
- Error codes data flow
- Faq data flow
- General information data flow
- Technical information data flow
- Reporting API v3
- Getting started
- Methods
- Parameters
- Technical information
- REST API
- Campaigns
- Custom variables
- Getting started rest
- Methods rest
- Response structure parameters rest
- Fixed periods
- Parameters compatibility
- Relative periods
- Structure of the response
- “code” parameter
- “columns” parameter
- “evo” parameter
- “filter” parameter
- “include” parameter
- “lng” parameter
- “max-results” parameter
- “page-num” parameter
- “period” parameter
- “period” parameter: “H” v. “He” & “MN” v. “MNe”
- “retention” parameter
- “segmentdesc” parameter
- “segment” parameter
- “sep” parameter
- “sort” parameter
- “space” parameter
- Technical specifications rest
- Data flow
-
Data collection
- Android
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Users
- Apple
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Users
- General
- Cddc renew staging process
- Changelog
- Craft your hit
- Encoded parameters
- Server side cookie management
- Supported taggings
- Tagging deletion
- Utilisation of dispatch sdks
- JavaScript
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Partners javascript
- Users
- Piano Analytics
- Event tagging piano analytics
- Getting started piano analytics
- Piano analytics tagging
- Feeding piano analytics with as2 tagging
- Tagging custom properties sdk
- Android