AnalyticsHelper.Setup() in PRISM / MVVM Architecture

Feb 10, 2014 at 4:54 AM
Is there a unique way we have to call the setup method when dealing with MVVM architecture?

I'm currently using PRISM and finding that the events don't throw exceptions, but also don't register data.

I've currently got GA tracking implemented in other 8.0 standard applications so i'm confident it's not a configuration problem.

Any thoughts?
Feb 14, 2014 at 5:21 PM
Lucas, can you please provide app sample with prism and w8ga integrated in your way?
Actually, you will still need some app.xaml.cs manipulations to initialize tracker (because we need app/frame reference), and then you can use .TrackEvent method in your ViewModels.
Other option is to use Bootstrapper (not sure if it still exists in Prism).
Feb 15, 2014 at 12:22 AM
Here's a gist of my current App.xaml.cs -

I wasn't sure how w8ga was structured, but you're saying it needs a reference to the app / frame? how would you achieve that in this context?

I'm currently calling it in my OnLaunchApplication, where should I be calling it? Also, is there any way to check if it's working without using fiddler to monitor requests or watching google analytics?
Feb 15, 2014 at 1:48 AM
Edited Feb 15, 2014 at 1:48 AM
In your gist what is the other part of the partial class App?

If you look at the sample App.xaml.cs, you'll see .Setup() is called in the very end of OnLaunched method (I don't see this method in your gist, only OnLaunchApplication) 8.1 Google Analytics/SampleAppWithGA/App.xaml.cs

My guess is to call AnalyticsHelper.Setup(); in at the end of your OnLaunchApplication.
Feb 15, 2014 at 2:02 AM
I've updated the gist to include the base class, and the methods available to it.

I have tried placing it at the end of the OnLaunchApplication method (before the return) but it doesn't appear to do anything.

Any other thoughts?
Feb 15, 2014 at 5:25 AM
Send me the prism dlls for Win8, but I'd suggest to use
    protected override void OnLaunched(LaunchActivatedEventArgs args);
this method to init w8ga
Feb 15, 2014 at 8:16 AM
You can find the prism dll's here -

I tried putting the Setup method within the OnLaunched with no direct effect.
Feb 15, 2014 at 1:59 PM
Hmm, OnLaunchApplication should be fine.
You also need to subscribe to navigation events.
Try using INavigationService or rootFrame for that purpose.

Do not forget this in app.xaml
       <a:GoogleAnalyticsSettings x:Key="GoogleAnalytics" WebPropertyId="UA-11111111-2" />
Here is a howto for you, make sure you did all steps: