How to use Google Analytics in progressive web applications that can be disabled?

My site is a progressive web application (one page / SPA) that works offline.

I would like to use Google Analytics, but I donโ€™t know how to report events in this case, especially since the device can be disconnected.

Is there a good way to do this?

+4
source share
2 answers

One strategy is to record analytics events, store them locally and replay them online: Employees in Production discussed this in detail and some source code โ€” search in the offline section of Google Analytics.

+7

, . "" Google Analytics Made Easy" , npm install --save-dev sw-offline-google-analytics, JavaScript:

importScripts('path/to/offline-google-analytics-import.js');
goog.offlineGoogleAnalytics.initialize();

, , - .

+3

Source: https://habr.com/ru/post/1618027/


All Articles