How to specify what should and shouldn't be tracked as a session (not event) when we add Google Analytics to an iOS app

五迷三道 提交于 2019-12-08 09:52:48

问题


If we instantiate session (not event, action or screen) tracking with Google Analytics for an iOS or Watch app, is there any way to specify what should and shouldn't be tracked as a session for example not to call the start lifecycle tracking on each launch -- e.g. I don't want background tasks or resuming the watch app or activating the glance to count as sessions. As a developer, do I have control over it to filer the session tracking data before sending to Google or all session tracking data are automatically dispatched to Google? currently I call this function in AppDelegate didFinishLaunchingWithOptions

(void) initializeGoogleAnalytics: (NSString * ) containerFilename {

 if ([self googleTagManager] == nil) {

  TAGManager * tagManager = [TAGManager instance];

  [tagManager setLogger: [TWNGTMLogger logger]];

  [tagManager setDispatchInterval: 20.0];

  [tagManager setDispatchInterval: 1.0];

  [self setGoogleTagManager: tagManager];

  //Open GTM tag container (async)

  [TAGContainerOpener openContainerWithId: containerFilename tagManager: [self googleTagManager] openType: kTAGOpenTypePreferFresh timeout: nil notifier: self];

  DMLogInfo(DebugLogTypeTracking, @ "Google Analytics initialized, container: %@, version: %@", containerFilename, kGAIVersion);

 }
}

回答1:


1) Is there a way to turn off or turn on Session Tracking in GTM code on iOS?

There's not a way to adjust session tracking itself using the GTM UI or the datalayer, other than preventing GA tags from firing (mentioned below).

2) Is there a way to AVOID session tracking if the app is launched in background?

The main way is to prevent the tag from firing when the app is opened in the background would be to set up a "blocking trigger" that looks for an event the indicates the app was launched in the background. Then, even if datalayer events were being fired telling the tag to fire, the blocking trigger would prevent the tag from firing, and therefore prevent a session from starting.



来源:https://stackoverflow.com/questions/38107646/how-to-specify-what-should-and-shouldnt-be-tracked-as-a-session-not-event-whe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!