#237: Added Google Analytics SDK

This commit is contained in:
Patrick Santana 2012-10-25 15:55:28 +02:00
parent 6be03dde80
commit aec0152376
23 changed files with 3925 additions and 0 deletions

View file

@ -0,0 +1,21 @@
//
// BasicExampleAppDelegate.h
// Google Analytics iOS SDK.
//
// Copyright 2009 Google Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GANTracker.h"
@interface BasicExampleAppDelegate : NSObject <UIApplicationDelegate,
UITabBarControllerDelegate,
GANTrackerDelegate> {
UIWindow *window_;
UITabBarController *tabBarController_;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@end

View file

@ -0,0 +1,68 @@
//
// BasicExampleAppDelegate.m
// Google Analytics iOS SDK.
//
// Copyright 2009 Google Inc. All rights reserved.
//
#import "BasicExampleAppDelegate.h"
// **************************************************************************
// Replace this string with your Analytics account ID!
// **************************************************************************
static NSString *const kAnalyticsAccountId = @"UA-00000000-1";
// Dispatch period in seconds.
static const NSInteger kDispatchPeriodSeconds = 10;
@implementation BasicExampleAppDelegate
@synthesize window = window_;
@synthesize tabBarController = tabBarController_;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[GANTracker sharedTracker] startTrackerWithAccountID:kAnalyticsAccountId
dispatchPeriod:kDispatchPeriodSeconds
delegate:self];
NSError *error = nil;
if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1
name:@"iOS1"
value:@"iv1"
withError:&error]) {
NSLog(@"setCustomVariableAtIndex failed: %@", error);
}
[self.window addSubview:self.tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}
#pragma mark -
#pragma mark GANTrackerDelegate methods
- (void)hitDispatched:(NSString *)hitString {
NSLog(@"Hit Dispatched: %@", hitString);
}
- (void)trackerDispatchDidComplete:(GANTracker *)tracker
eventsDispatched:(NSUInteger)hitsDispatched
eventsFailedDispatch:(NSUInteger)hitsFailedDispatch {
NSLog(@"Dispatch completed (%u OK, %u failed)",
hitsDispatched, hitsFailedDispatch);
}
#pragma mark -
#pragma mark Memory management
- (void)dealloc {
[tabBarController_ release];
[window_ release];
[super dealloc];
}
@end

View file

@ -0,0 +1,20 @@
//
// FirstViewController.h
// BasicExample
//
// Created by Farooq Mela on 4/10/12.
// Copyright 2012 Google, Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController {
@private
UIButton *button_;
}
@property (nonatomic, assign) IBOutlet UIButton *button;
- (IBAction)buttonClicked:(id)sender;
@end

View file

@ -0,0 +1,31 @@
//
// FirstViewController.m
// BasicExample
//
// Created by Farooq Mela on 4/10/12.
// Copyright 2012 Google, Inc. All rights reserved.
//
#import "FirstViewController.h"
#import "GANTracker.h"
@implementation FirstViewController
@synthesize button = button_;
- (void)viewDidAppear:(BOOL)animated {
NSLog(@"First View appeared!");
[[GANTracker sharedTracker] trackPageview:@"FirstView" withError:nil];
[super viewDidAppear:animated];
}
- (IBAction)buttonClicked:(id)sender {
NSLog(@"First View button clicked!");
[[GANTracker sharedTracker] trackEvent:@"Button"
action:@"Click"
label:@"First Button"
value:-1
withError:nil];
}
@end

View file

@ -0,0 +1,20 @@
//
// SecondViewController.h
// BasicExample
//
// Created by Farooq Mela on 4/10/12.
// Copyright 2012 Google, Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController {
@private
UIButton *button_;
}
@property (nonatomic, assign) IBOutlet UIButton *button;
- (IBAction)buttonClicked:(id)sender;
@end

View file

@ -0,0 +1,31 @@
//
// SecondViewController.m
// BasicExample
//
// Created by Farooq Mela on 4/10/12.
// Copyright 2012 Google, Inc. All rights reserved.
//
#import "SecondViewController.h"
#import "GANTracker.h"
@implementation SecondViewController
@synthesize button = button_;
- (void)viewDidAppear:(BOOL)animated {
NSLog(@"Second View appeared!");
[[GANTracker sharedTracker] trackPageview:@"SecondView" withError:nil];
[super viewDidAppear:animated];
}
- (IBAction)buttonClicked:(id)sender {
NSLog(@"Second View button clicked!");
[[GANTracker sharedTracker] trackEvent:@"Button"
action:@"Click"
label:@"Second Button"
value:-1
withError:nil];
}
@end