This project has moved and is read-only. For the latest updates, please go here.

Xamarin support

Jul 11, 2014 at 11:03 AM
In the New Features of 1.2.01 version mentioned that the SDK can be used with Xamarin platform. I tried to use the SDK in a Xamarin.iOS project, but unsuccessfully.
First of all, It looks like the installation has not been completed, because there are was no EasyTracker class available. I tried to use Tracker class directly (with the similar way as in the SDK) and got exception:
System.TypeLoadException: A type load exception has occurred.
  at GoogleAnalytics.Core.TrackerManager.GoogleAnalytics.Core.IServiceManager.SendPayload (GoogleAnalytics.Core.Payload payload) [0x00008]
    in c:\Users\Tim\Desktop\googleanalyticssdk\Core\Common\TrackerManager.cs:56
  at GoogleAnalytics.Core.Tracker.SendPayload (GoogleAnalytics.Core.Payload payload) [0x0003f]
    in c:\Users\Tim\Desktop\googleanalyticssdk\Core\Common\Tracker.cs:316
  at GoogleAnalytics.Core.Tracker.SendView (System.String screenName) [0x0001f]
    in c:\Users\Tim\Desktop\googleanalyticssdk\Core\Common\Tracker.cs:224 at
... my calling code
This forced me to use another library to work with Google Analytics, but I believe my issue should be reported.
Jul 30, 2014 at 4:36 PM
The short answer is: you need to use the core component of the SDK directly without EasyTracker in Xamarin (same is true for platforms like WPF or Silverlight 5).

Here's how it works: the SDK is now divided into 2 parts, the core and the EasyTracker. The core is a PCL and can be used directly by any platform. The core contains everything you need to work with GA. The EasyTracker part is just a layer on top of the core that helps automatically configure the core component for the given platform (e.g. screen resolution, automatic exception logging, ...etc). I don't provide an EasyTracker version that works with Xamarin, but because the core is a PCL, it will work fine as long as you configure it correctly. Here's a code snippet demonstrating how to use the core by itself:
PlatformInfoProvider platformInfo = new PlatformInfoProvider();
// TODO: set properties on the platformInfo object for your environment.
Tracker tracker = new Tracker("UA-39959863-1", platformInfo, GAServiceManager.Current);
tracker.AppName = "My agent";
tracker.AppVersion = "1.0";
tracker.SendEvent("OnInvoke", "action", "label", 0);
Let me know if you have further questions,