google / ioweb2015

I/O Web App 2015
https://events.google.com/io2015/
Apache License 2.0
686 stars 122 forks source link

Notifications: record analytics for every showNotification #1524

Open ebidel opened 9 years ago

ebidel commented 9 years ago

It was a mistake not to record these calls to GA. We know how many notifications were sent from GCM, and how many user clicks on notifications, but not how many push events the sw's actually recieved :(

https://github.com/GoogleChrome/ioweb2015/blob/e33352f89034e77f54afdb1fc685439f3962803a/app/scripts/shed/push-notifications.js

cc @jeffposnick

jeffposnick commented 9 years ago

It would be messy to go about doing that.

AFAIK, the standard Google Analytics JS library won't play nicely with the ServiceWorkerGlobalScope, and I don't think there's an official way of constructing GA ping URLs "by hand".

One approach would be to use IndexedDB to queue up details about the incoming push events and then generate GA pings based on those IDB entries whenever the site is loaded, e.g. here. But that will end up undercounting, since there's a percentage of users who would get a push event but never bother clicking through to the website, or who clickthrough the website after X number of days have passed.