ios - error with adding google analytics -
i have been trying add google analytics app in development following online text tutorial ok @ first right @ end error on code... (specifically code in .m file)
two things:
when go on google analytics, dont register information , line of code right below registers error when try compile , run
another thing in code there section im supposed put tracker id google analytics?
p.s ok include link tot tutorial following guys know im talking about? dont wanna banned thought ask first...
- (ibaction)tappedbuttonone:(id)sender { id<gaitracker> tracker = [[gai sharedinstance] defaulttracker]; [tracker sendeventwithcategory:@"myfirstscreen" withaction:@"buttonpress" withlabel:@"buttonone" withvalue:nil]; }
here code have in .h
#import <uikit/uikit.h> #import <iad/iad.h> #import "gaitrackedviewcontroller.h" @interface viewcontroller : gaitrackedviewcontroller <adbannerviewdelegate> @property (retain, nonatomic) iboutlet adbannerview *banner; @property (retain, nonatomic) iboutlet uitextview *txtinfo; - (ibaction)tappedbuttonone:(id)sender; @end
and here code have in .m
} - (void)bannerview:(adbannerview *)banner didfailtoreceiveadwitherror:(nserror *)error { } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (void)dealloc { [_banner release]; [_txtinfo release]; [super dealloc]; } - (ibaction)tappedbuttonone:(id)sender { id<gaitracker> tracker = [[gai sharedinstance] defaulttracker]; [tracker sendeventwithcategory:@"myfirstscreen" withaction:@"buttonpress" withlabel:@"buttonone" withvalue:nil]; } @end
another thing in code there section im supposed put tracker id google analytics?
yes, need initialize tracker in application delegate.
see google analytics sdk ios - getting started guide, section 2 explains:
to initialize tracker, import
gai.h
header in application delegate.m
file , add code application delegate'sapplication:didfinishlaunchingwithoptions:
method:
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // optional: automatically send uncaught exceptions google analytics. [gai sharedinstance].trackuncaughtexceptions = yes; // optional: set google analytics dispatch interval e.g. 20 seconds. [gai sharedinstance].dispatchinterval = 20; // optional: set logger verbose debug information. [[[gai sharedinstance] logger] setloglevel:kgailoglevelverbose]; // initialize tracker. id<gaitracker> tracker = [[gai sharedinstance] trackerwithtrackingid:@"ua-xxxx-y"]; }
it's here need provide tracker tracking id initializing tracker trackerwithtrackingid
method.
the rest of code looks fine, , should work expected when you've added code above application delegate.
note: can take 24 hours events show in google analytics after have been sent app. if there's still nothing showing after 1 day, might need check code again.
Comments
Post a Comment