# Desktop PWA works with Discourse!

**URL:** https://meta.discourse.org/t/desktop-pwa-works-with-discourse/86348
**Category:** Announcements
**Created:** [April 28, 2018, 2:23am UTC](https://meta.discourse.org/t/desktop-pwa-works-with-discourse/86348 "2018-04-28T02:23:24Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [April 28, 2018, 3:30am UTC](https://meta.discourse.org/t/desktop-pwa-works-with-discourse/86348/3 "2018-04-28T03:30:57Z")

</div>

> [@sam](#):
>
> Luckily we have window.matchMedia(‘(display-mode: standalone)’).matches to detect if we are in this mode so its simple to make a component to clean this stuff up.

One thing I played with a bit is adding stats like:

- Pageviews from PWA
- Installations

To the Discourse Admin Dashboard and/or Google Analytics.

We can detect pageviews with that media query and installs with:

```plaintext
window.addEventListener('beforeinstallprompt', function(e) {
  // beforeinstallprompt Event fired

  // e.userChoice will return a Promise.
  // For more details read: https://developers.google.com/web/fundamentals/getting-started/primers/promises
  e.userChoice.then(function(choiceResult) {

    console.log(choiceResult.outcome);

    if(choiceResult.outcome == 'dismissed') {
      console.log('User cancelled home screen install');
    }
    else {
      console.log('User added to home screen');
    }
  });
});

```

---

_[View the full topic](https://meta.discourse.org/t/desktop-pwa-works-with-discourse/86348)._
