Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to track the number of pwa installations

I'm using the

 window.addEventListener('beforeinstallprompt', e => {
  e.userChoice.then(choiceResult => {
    ga('send', 'event', 'A2H', choiceResult.outcome);
    alert('AAAAAAAAAAAAAa',choiceResult.outcome)
  });
});

but this event not work with event default of pwa, only work with one button custom generating deferredPrompt.prompt(); what i can do?

like image 979
mascDriver Avatar asked Sep 14 '25 23:09

mascDriver


1 Answers

I don't have any PWA experience, but I found these two resources that may help.

1. window.addEventListener('appinstalled', function() { });

window.addEventListener('appinstalled', function() { 
  console.log('Thank you for installing our app!'); 
});
// or 
window.onappinstalled = function() { 
  console.log('Thank you for installing our app!'); 
};

2. this YouTube video

I wanted to learn more about PWAs last week and stumbled across this youtube video. It has some good info. It talks about deferring the event object from 'beforeinstallprompt' so you can use it later in your own "Install" prompt.

like image 71
DJ House Avatar answered Sep 16 '25 13:09

DJ House