Google Analytics iPhone SDK delegate and multiple accounts

I use the Google Analytics SDK in my iPhone application. I worked with the following code:

AppDelegate .m :

[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-xxxxxxx-1"
                                       dispatchPeriod:10
                                             delegate:nil]; 


if (![[GANTracker sharedTracker] trackPageview:string withError:&error]) {

    NSLog(@"Error happened with google analytics tracking 2, %@", error);

}else {
    NSLog(@"OK");

}

In my analytics account, I got the desired results. Then I decided (don't ask why) to try sending my tracking data to a second analytics account. For the curious: one account is used for web page and iPhone statistics, and the other is for iPhone only.

My brilliant plan was to create 1st sharedTracker, send it, stop it and do the same for the second:

AppDelegate .h:
@interface AppDelegate : NSObject <UIApplicationDelegate, GANTrackerDelegate>    

//implementation
AppDelegate .m:
//1st tracking account
[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-xxxxxxx-1"
                                       dispatchPeriod:10
                                             delegate:self]; 


if (![[GANTracker sharedTracker] trackPageview:string withError:&error]) {

    NSLog(@"Error happened with google analytics tracking, %@", error);

}else {
    NSLog(@"1. GAnalytics: OK");

}

[[GANTracker sharedTracker] stopTracker];

//2nd tracking account
[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-zzzzzzzz-1"
                                       dispatchPeriod:10
                                             delegate:self]; 


if (![[GANTracker sharedTracker] trackPageview:string withError:&error]) {

    NSLog(@"Error happened with google analytics tracking, %@", error);

}else {
    NSLog(@"2. GAnalytics: OK");

}

[[GANTracker sharedTracker] stopTracker];
- (void)trackerDispatchDidComplete:(GANTracker *)tracker
              eventsDispatched:(NSUInteger)eventsDispatched
          eventsFailedDispatch:(NSUInteger)eventsFailedDispatch{

NSLog(@"For the love of Got, why don't you say something?");
}

, , , , SDK , , , ! 0 ( -1 ), ...

, : 2 gAnalytics , - :)

, Luka

+3
2

, , .. Google Analytics. , [GANTracker sharedTracker] - , , sharedTracker.

, , , , [[GANTracker sharedTracker] stopTracker], . , .

"", Google Analytics sqlite, googleanalytics.sql. . "sqlite3 googleanalytics.sql", sqlite, .. ID , , , , .

+2

Google , iOS SDK v2

.

0

All Articles