The Google Analytics SDK is designed makes it easy to connect .net Applications to Google Analytics.
The Google Analytics SDK uses the Google Analytics measurement protocol to record Hits via HTTP POST or GET requests directly to Google Analytics. The Google Analytics SDK also supports the debug endpoint which will allows developers to test and validate their hits before releasing their applicaitons to production.
The Google Analytics SDK supports tracking for the following interaction (Hit) types: 'pageview', 'screenview', 'event', 'transaction', 'item', 'social', 'exception', 'timing'.
// Create Web tracker
var tracker = Tracker.BuildWebTracker("UA-9183475-1");
// Create new Page view hit.
var hit = new PageViewHit(tracker, "location", "hostname", "path", "title");
// Build hit request.
var request = (Hitrequest)tracker.CreateHitRequest(hit);
// Debug hit request.
var debugRequest = Task.Run(() => request.ExecuteDebugAsync());
debugRequest.Wait();
Console.Write(debugRequest.Result.RawResponse);
// Execute hit request.
var collectRequest = Task.Run(() => request.ExecuteCollectAsync());
collectRequest.Wait();
Console.Write(collectRequest.Result.RawResponse);
Additional samples can be found in the Quick start project - Tutorials
I have not added support for batching yet. If your interested in it please let me know.
This Google Analytics SDK is not an offical Google SDK It was created by me to help the Google Analytics community as there is no active development on any other SDKs currently. I intend to support .Net Standard, .net core, and .net classic application types to begin with. I hope to support Xamarin and Universal windows Applications soon.
I accept contributions to code, samples, and docs. Please submit pull requests.