Esta página ainda não está disponível em Português, por isso está a ler a versão em inglês.

Detect if your PWA is installed, and count installs

Running in a tab or as an app? Here is how to know.

Instalação Intermediário 1 min de leitura Revisado em 27 de nov. de 2026

Is it running as an installed app right now?

function displayMode() {
  if (navigator.standalone) return 'standalone-ios';
  for (const m of ['fullscreen', 'standalone', 'minimal-ui', 'window-controls-overlay']) {
    if (matchMedia(`(display-mode: ${m})`).matches) return m;
  }
  return 'browser';
}

Send displayMode() with every page view as a custom dimension. In CSS, use @media (display-mode: standalone).

Was it launched from the icon?

Give your manifest a tagged start URL:

"start_url": "/?source=pwa"

Launches from the icon (and from shortcuts, if you tag them too) carry the parameter. Count them in analytics, then remove the parameter with history.replaceState so it is not shared.

Did they install it?

  • Chromium: listen for appinstalled, and record userChoice.outcome from beforeinstallprompt (custom install button).
  • iOS: there is no event. The first launch in standalone mode is your best signal: store a flag in localStorage and send an "installed launch" event once.

Is it installed, from a normal tab?

navigator.getInstalledRelatedApps() (Chromium) can tell a page whether the user has installed a related app: your Android app, or your PWA itself if you list it in related_applications with "platform": "webapp" and the manifest URL.

const apps = await navigator.getInstalledRelatedApps?.() ?? [];
if (apps.length) hideInstallPromo();

Support is limited (mainly Chrome on Android and Windows), so treat it as a bonus.

Respect privacy

Display mode and install events are not personal data in themselves, but they go through your analytics, so they follow your consent rules. PWA.live only sends them to Google Analytics in production, after cookie consent. More in PWA analytics.

Compatibilidade de navegadores

Compatibilidade dos navegadores com recursos de PWA
RecursoChrome / Edge desktopChrome AndroidSafari iOS / iPadOSSafari macOSFirefox desktopFirefox AndroidSamsung Internet
beforeinstallprompt (own install button) Chrome / Edge desktop: Sim Chrome Android: Sim Safari iOS / iPadOS: Não Safari macOS: Não Firefox desktop: Não Firefox Android: Não Samsung Internet: Sim

Ver a tabela completa