title: Implementing Google Analytics for iOS
body: <p>As someone coming from experience with Flurry Analytics, can someone explain the correct location for implementing event tracking and custom variables in Google Analytics for iOS? The example that Google provides shoves everything into the AppDelegate. Not sure if they did that for the sake of brevity or not.<br /><br />I can see why the init call goes in the AppDelegate:</p>
  
  <pre><code>//AppDelegate.m
  - (void)applicationDidFinishLaunching:(UIApplication *)application {
  
     [[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-0000000-1"
                                      dispatchPeriod:kGANDispatchPeriodSec
                                            delegate:nil];
  
     //...
  
  }
  </code></pre>
  
  <p>But what about these calls that collect specific data related to a specific view? Can they go into their respective ViewControllers instead of the AppDelegate?</p>
  
  <pre><code>[[GANTracker sharedTracker] setCustomVariableAtIndex:1
                                                     name:@"iPhone1"
                                                    value:@"iv1"
                                                withError:&amp;error]
  
  [[GANTracker sharedTracker] trackEvent:@"my_category"
                                     action:@"my_action"
                                      label:@"my_label"
                                      value:-1
                                 withError:&amp;error]
  
  [[GANTracker sharedTracker] trackPageview:@"/app_entry_point"
                                 withError:&amp;error]
  </code></pre>
  
  <p><strong>Questions</strong></p>
  
  <p>1) What Google Analytics for iOS calls shown above need to be in the AppDelegate?<br />
  2) What Google Analytics for iOS calls shown above can be put into the ViewControllers?</p>
  
  <p>Thanks</p>