title: Integrating Google Analytics with xamarin android app
body: <p>I am working on an Android app using Xamarin. I have tried to follow <a href="https://developers.google.com/analytics/devguides/collection/android/v4/" rel="nofollow noreferrer">this</a> tutorial from Google in which they ask me to edit the <code>build.gradle</code> file but I don't have this file in my solution (maybe because I am in Xamarin, I don't know). So I have searched for an other tutorial especially for Xamarin user.
  I have found <a href="https://theconfuzedsourcecode.wordpress.com/2015/07/06/lets-add-google-analytics-to-your-xamarin-android-app-_/" rel="nofollow noreferrer">this</a> one and those are my code till now:</p>
  
  <pre><code>public class GAService
  {
      public string TrackingId = "XX-XXXXXXXX-X";
  
      private static GoogleAnalytics GAInstance;
      private static Tracker GATracker;
  
      #region Instantiation ...
      private static GAService thisRef;
      private GAService()
      {
  
      }
  
      public static GAService GetGASInstance()
      {
          if (thisRef == null)
  
              thisRef = new GAService();
          return thisRef;
      }
      #endregion
  
      public void Initialize(Context AppContext)
      {
          GAInstance = GoogleAnalytics.GetInstance(AppContext.ApplicationContext);
          GAInstance.SetLocalDispatchPeriod(10);
  
          GATracker = GAInstance.NewTracker(TrackingId);
          GATracker.EnableExceptionReporting(true);
          GATracker.EnableAdvertisingIdCollection(true);
          GATracker.EnableAutoActivityTracking(true);
      }
  
      public void Track_App_Page(String PageNameToTrack)
      {
          GATracker.SetScreenName(PageNameToTrack);
          GATracker.Send(new HitBuilders.ScreenViewBuilder().Build());
      }
  
      public void Track_App_Event(String GAEventCategory, String EventToTrack)
      {
          HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder();
          builder.SetCategory(GAEventCategory);
          builder.SetAction(EventToTrack);
          builder.SetLabel("AppEvent");
  
          GATracker.Send(builder.Build());
      }
  
      public void Track_App_Exception(String ExceptionMessageToTrack, Boolean isFatalException)
      {
          HitBuilders.ExceptionBuilder builder = new HitBuilders.ExceptionBuilder();
          builder.SetDescription(ExceptionMessageToTrack);
          builder.SetFatal(isFatalException);
  
          GATracker.Send(builder.Build());
      }
  }
  </code></pre>
  
  <p>I am getting the same error in three places in the above code, the first is here: <code>private static GoogleAnalytics GAInstance;</code> which says <code>The namescape 'GoogleAnalytics' could not be found</code>.
  The second is here:<code>private static Tracker GATracker;</code> saying <code>The namescape 'Tracker' could not be found</code>.
  The third is here: <code>HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder();</code> saying <code>The namescape 'HitBuilders' could not be found</code>.
  Any solutions for my problem ?
  Thank you in advance</p>