iOS SDK
- Download OWOX BI Streaming plugin for iOS applications: OBIStreaming.zip.
- Add OBIStreaming.framework library to your iOS application.
- Import the library in AppDelegate.m:
#import <OBIStreaming/OBIStreaming.h>
- Initialize streaming and define your Google Analytics web-property ID:
— (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[OBIStreaming sharedInstance] setTrackerIds:[NSSet setWithArray:@[@"UA-XXXX-X"]]]; }
- Session data requires you to define session scope custom dimension where you collect session ID.
Here is a snippet for applications using iOS Google Analytics Services SDK to set up session ID data collection. Copy it and replace XX with custom dimension number.
- (NSString *)hitIdWithClientIdentifier:(NSString *)clientId { if ([clientId length] == 0) { return nil; } NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970]; return [NSString stringWithFormat:@"%@_%.0f", clientId, timeInterval * 1000]; } NSString *client_id = [[[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-X"] get:kGAIClientId]; [tracker send:[[[GAIDictionaryBuilder createScreenView] set:[self hitIdWithClientIdentifier:client_id] forKey:[GAIFields customDimensionForIndex:XX]] build]];
- Verify that Google Analytics hits are additionally sent to google-analytics.bi.owox.com domain and contain &cdXX parameter with values.
GTM
- Download OWOX BI Streaming plugin for iOS applications: OBIStreaming.zip.
- Add OBIStreaming.framework library to your iOS application.
- Import the library in AppDelegate.m:
#import <OBIStreaming/OBIStreaming.h>
- Initialize streaming and define your Google Analytics web-property ID:
— (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[OBIStreaming sharedInstance] setTrackerIds:[NSSet setWithArray:@[@"UA-XXXX-X"]]]; }
- Session data requires you to define session scope custom dimension where you collect session ID.
Here is a snippet for applications using iOS Google Tag Manager SDK to set up GTM Function Call variable with session ID:
#import "OBIStreamingGTMHitIdFunctionCallMacroHandler.h" - (void)containerAvailable:(TAGContainer *)container { // Important note: containerAvailable may be called from a different thread, marshall the // notification back to the main thread to avoid a race condition with viewDidAppear. dispatch_async(dispatch_get_main_queue(), ^{ self.container = container; // Register a function call macro handler using the macro name defined // in the Google Tag Manager web interface. [self.container registerFunctionCallMacroHandler:[[OBIStreamingGTMHitIdFunctionCallMacroHandler alloc] init] forMacro:kOBIStreamingGTMMacroFunctionHitId]; }); }
Import required library:
You need to collect session ID custom dimension data from this variable in every Google Analytics tag fired in your application.
- Verify that Google Analytics hits are additionally sent to google-analytics.bi.owox.com domain and contain session ID custom dimension with values.
Google Firebase
You can also use Google Firebase for data collection from your iOS app in Google BigQuery in real time.
0 Comments