Skip to content

Instantly share code, notes, and snippets.

@Aaronontheweb
Created November 6, 2012 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aaronontheweb/4021432 to your computer and use it in GitHub Desktop.
Save Aaronontheweb/4021432 to your computer and use it in GitHub Desktop.
Tracking navigation events in WinRT apps using MarkedUp Analytics (https://markedup.com/)
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
//markedup init
MarkedUp.AnalyticClient.Initialize("{YOUR API KEY from MarkedUp.com here!}");
// Do not repeat app initialization when already running, just ensure that
// the window is active
if (args.PreviousExecutionState == ApplicationExecutionState.Running)
{
Window.Current.Activate();
return;
}
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
var rootFrame = new Frame();
// Create a Frame to act navigation context and navigate to the first page
if (!rootFrame.Navigate(typeof(MainPage)))
{
throw new Exception("Failed to create initial page");
}
//hook rootFrame into MarkedUp so we can track navigation across it
MarkedUp.AnalyticClient.RegisterNavigationFrame(rootFrame);
// Place the frame in the current Window and ensure that it is active
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment