1

I would like get GA in my apps. I've tried to do this:

I used this Google Analytics SDK for iOS v3 (Beta)- https://developers.google.com/analytics/devguides/collection/ios/v3/

I've followed all the steps of the documentation. also already tried Linker errors when trying to install new Google Analytics 3.0 Beta

enter image description here

In my AppDelegate.h

#import <UIKit/UIKit.h>
#import "GAI.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property(nonatomic, strong) id<GAITracker> tracker;
@property (strong, nonatomic) UIWindow *window;

@end

In my AppDelegate.m

#import "AppDelegate.h"
#import "GAI.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [GAI sharedInstance].trackUncaughtExceptions = YES;

    // Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
    [GAI sharedInstance].dispatchInterval = 20;

    // Optional: set Logger to VERBOSE for debug information.
    [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];

    // Initialize tracker.
    id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-47246605-1"];

    [GAI sharedInstance].optOut = YES;
    [GAI sharedInstance].trackUncaughtExceptions = YES;
    [GAI sharedInstance].dispatchInterval = 0;

    return YES;
}

ViewController.h

#import <UIKit/UIKit.h>
#import "GAI.h"
#import "GAITrackedViewController.h"

@interface ViewController : GAITrackedViewController
@end

ViewController.m

#import "ViewController.h"
#import "GAI.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.screenName = @"Home Screen";

}

Link for my project test:https://www.dropbox.com/s/j3ufrv55xym82nc/TesteAnalytics.zip

Community
  • 1
  • 1
Claudia Mardegan
  • 567
  • 4
  • 14
  • How to determine which framework you are missing: 1) look at names in "undefined symbols" section; 2) google them (without _OBJC_CLASS_$_ part); 3) click on the link to Apple documentation for that class and read framework name. – Kreiri Jan 17 '14 at 16:30

2 Answers2

0

Google Analytics uses the CoreData.framework, and the linker can't find it. (NSManagedEntity, NSManagedContext, etc are CoreData classes)

Did you add the framework to your project?

Jeroen Bouma
  • 593
  • 6
  • 16
0

I change this and work now.

#import <CoreData/CoreData.h>
#import "AppDelegate.h"
#import "GAI.h"

@implementation AppDelegate

static NSString *const kTrackingId = @"UA-47244310-1";
static NSString *const kAllowTracking = @"allowTracking";

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [GAI sharedInstance].optOut = ![[NSUserDefaults standardUserDefaults] boolForKey:kAllowTracking];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    NSDictionary *appDefaults = @{kAllowTracking: @(YES)};
    [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
    // User must be able to opt out of tracking
    [GAI sharedInstance].optOut =
![[NSUserDefaults standardUserDefaults] boolForKey:kAllowTracking];
    // Initialize Google Analytics with a 120-second dispatch interval. There is a
    // tradeoff between battery usage and timely dispatch.
    [GAI sharedInstance].dispatchInterval = 120;
    [GAI sharedInstance].trackUncaughtExceptions = YES;
    self.tracker = [[GAI sharedInstance] trackerWithName:@"TesteDelegate"
                                          trackingId:kTrackingId];

    return YES;
}
Claudia Mardegan
  • 567
  • 4
  • 14