mascDriver
mascDriver

Reputation: 75

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?

Upvotes: 4

Views: 2294

Answers (1)

DJ House
DJ House

Reputation: 1397

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.

Upvotes: 6

Related Questions