Hi Mark, I went with your original idea to "split the project in two". All the core functionality is now included in it's own assembly "GoogleAnalytics.Core" that you can use by itself in a background agent project. This core assembly
should definitely pass all cert tests for background agents as it does not contain any platform or UI specific APIs found on the unsupported APIs list.
The nice part (besides support for background agents) is that this approach also opened the door for the core assembly to be distributed as a PCL (portable class library) that can be used on other platforms such as WPF, Silverlight, or Xamarin.
The down-side is that there is more work to be done during initialization since PCL compatibility doesn't support loading local resources or determining things like screen size.
Hoping everyone is happy with this decision. Overall, this felt like the right long term approach to solve this issue.
To set this up in your project:
1) Add the nuget package to your project same as before.
2) Remove the "GoogleAnalytics" project reference and the analytics.* files BUT leave just the project reference for "GoogleAnalytics.Core".
3) Add the
(for WP8) to your project to help provide platform specific info required by GA.
4) Create and initialize a tracker object that you can call the same way you would in a regular project. For example:
static Tracker tracker;
tracker = new Tracker("UA-39959863-1", new PlatformInfoProvider(), GAServiceManager.Current);
tracker.AppName = "My agent";
tracker.AppVersion = "1.0";
Application.Current.UnhandledException += UnhandledException;
private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
// An unhandled exception has occurred; break into the debugger
protected override void OnInvoke(ScheduledTask task)
tracker.SendEvent("OnInvoke", "action", "label", 0);