| Integrate your app / Windows integration | |
Integrate your Windows 8 C# app with Localytics.
<script src="/js/localytics.js"></script>
By default, the HTML5 library polls the app to see if the user is still using it, but on Windows 8 there are robust viewchange events, so this is not necessary.
var localyticsSession = LocalyticsSession("APP_KEY");
localyticsSession.open();
localyticsSession.upload();
                var onVisibilityChange = function (args) {
  var state = document["visibilityState"];
  if (state == "visible") {
    localyticsSession.open();
    localyticsSession.upload();
  }
  else if (state == "hidden") {
    localyticsSession.close();
    localyticsSession.upload();
  }
}; 
document.addEventListener("visibilitychange", onVisibilityChange, false);