Plugin.GoogleAnalytics

GoogleAnalytics Plugin for Xamarin...


Keywords
xamarin, pcl, xam.pcl, plugin, for, settings, analytics, google, android, xamarin.forms, ios, monoandroid, monodroid, monotouch, google-analytics, nuget, xamarin-forms
License
GPL-3.0
Install
Install-Package Plugin.GoogleAnalytics -Version 0.1.0

Documentation

GoogleAnalyticsPlugin for Xamarin Forms

Simple Google Analytics Plugin for Xamarin Forms.

This is my first plugin, it's a very basic Google Analytics utility for Xamarin Android, iOS and Forms. If you have any comments or suggestions, please let me know.

Setup

Platform Support

Platform Supported Version
Xamarin.iOS Yes iOS 8+
Xamarin.Android Yes API 15+
Windows Phone Silverlight No
Windows Phone RT No
Windows Store RT No
Windows 10 UWP No
Xamarin.Mac No

API Usage

Call CrossGoogleAnalytics.Current from any project or PCL to gain access to APIs.

public interface IGoogleAnalytics
{		
	bool EnableAdvertisingTracking {get;set;}

	void Report (string message, bool isFatal = false);
	void Report (Exception exception, bool isFatal = false);
	void Report (Exception exception, IDictionary<string, string> extraData, bool isFatal = false);
	void TrackEvent (string category, string action, string label, long value);
	void TrackPage (string pageName);
}

IMPORTANT

You must first initialize plugin

Android

On Android, in your main Activity's OnCreate (..) implementation, call:

GoogleAnalyticsImplementation.Init("UA-XXXXXXX-X", this);

iOS

In your AppDelegate's FinishedLaunching (..) implementation, call:

GoogleAnalyticsImplementation.Init("trackerName", "UA-XXXXXXX-X");

Usage

Simpliest way to report an exception:

CrossGoogleAnalytics.Current.Report(ex);

Track a page:

CrossGoogleAnalytics.Current.TrackPage("PageName");

Track an event:

CrossGoogleAnalytics.Current.TrackEvent("category", "action", "label", 0);