0

I have implemented 3 steps.

Step 1: I have Downloaded google analytics Library files and added this files to project,

  • GAI.h
  • GAITrackedViewController.h
  • GAITracker.h
  • GAITransaction.h
  • GAITransactionItem.h

  • libGoogleAnalytics.a

  • CoreData.framework
  • SystemConfiguration.framework

Step 2: Added this code in didFinishLaunchingWithOptions

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

   [UIApplication sharedApplication].statusBarHidden = NO;

    [GAI sharedInstance].trackUncaughtExceptions = YES;
    [GAI sharedInstance].dispatchInterval = 2;
    [GAI sharedInstance].debug=YES;
    [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-1"];

    return YES;
}

Step 3: In my HomeScreen view which loads after launch image i wrote this, I have updated this header to:

#import "GAITrackedViewController.h"

@interface BTSHomeViewController : GAITrackedViewController

and in BTSHomeViewController.m

- (void)viewDidLoad
{    ...
     self.trackedViewName = @"Home";
}

Note: I have wroteself.trackedViewName = @"Home"; only on firstpage not in all the Pages it is necessary to write in all pages ?

also LOG shows this warning:

ld: warning: directory not found for option '-L/Users/Supriya/Desktop/BTS with Analytics/BTS 2.1/BTS/BTS/GoogleAnalytics/Library'
ld: warning: directory not found for option '-F/Users/Supriya/Desktop/BTS with Analytics/BTS 2.1/BTS/../../Documents'
ld: warning: directory not found for option '-F/Users/Supriya/Desktop/BTS with Analytics/BTS 2.1/BTS/../../../Documents'

After writing this when i run my code in Device, google analytics doesn't show any active users.

Here is the snapshot of my framework folder in my project, am i forgetting adding any library ?

: Please help, what is the mistake ?

Thanks in advance.

Krunal
  • 6,440
  • 21
  • 91
  • 155
  • Have you created a GA account and changed the tracking ID ? – Mohamed Amine Sep 03 '13 at 13:43
  • No need to ask same question (http://stackoverflow.com/q/18585583/1603072) multiple times. You can always edit the question. – Bhavin Sep 03 '13 at 13:44
  • I have standard Google account, i have tried one simple project with same above steps it works fine but when i try to follow same steps in my apps it is not working :( – Krunal Sep 03 '13 at 13:45

2 Answers2

2
  1. Just to confirm, but you have used a tracking ID for a mobile app right? A tracking ID created for a web application will not give you anything when used in a mobile app.

  2. Once the initial set-up is done in App Delegate, tracking can just as easily be done with something like this - [[[GAI sharedInstance] defaultTracker] trackView:@"Screen name"];

OutOnAWeekend
  • 1,383
  • 1
  • 18
  • 36
1

According to the google documentation you should set trackedviewname in viewDidAppear instead of viewDidLoad.

To be sure that your ID is correct you should try to test analytics without the automatic screen measurement and using [[[GAI sharedInstance] defaultTracker] sendView:page];

Ben-J
  • 1,084
  • 8
  • 24