/GoogleAnalyticsPlugin

Google Analytics Plugin for Xamarin Forms

Primary LanguageC#GNU General Public License v3.0GPL-3.0

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);