From 97ec1efce2bdffd7eeadbbb024fc6f3ffaebfb1e Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 8 Jun 2018 19:50:41 +0200 Subject: Add GA events --- src/InstallNotification.vue | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/InstallNotification.vue') diff --git a/src/InstallNotification.vue b/src/InstallNotification.vue index 22e7a8c..a60ec9c 100644 --- a/src/InstallNotification.vue +++ b/src/InstallNotification.vue @@ -29,15 +29,25 @@ export default Vue.component('install-notification', { }, methods: { promptInstall: function(p) { + this.$ga.event('PWA', 'available'); p.preventDefault(); this.deferredPrompt = p; + this.deferredPrompt.userChoice.then((choiceResult) => { + this.$ga.event('PWA', 'popup', choiceResult.outcome); + this.deferredPrompt = null; + }); + }, + installed: function(e) { + this.$ga.event('PWA', 'installed'); }, }, created: function() { window.addEventListener('beforeinstallprompt', this.promptInstall); + window.addEventListener('appinstalled', this.installed); }, destroyed: function() { window.removeEventListener('beforeinstallprompt', this.promptInstall); + window.removeEventListener('appinstalled', this.installed); }, }); -- cgit v1.3.1