{"id":714,"date":"2019-11-11T09:48:25","date_gmt":"2019-11-11T09:48:25","guid":{"rendered":"http:\/\/pwa-for-wp.com\/docs\/?post_type=ht_kb&#038;p=714"},"modified":"2019-11-11T10:22:17","modified_gmt":"2019-11-11T10:22:17","slug":"how-to-use-offline-google-analytics-in-pwa","status":"publish","type":"ht_kb","link":"https:\/\/pwa-for-wp.com\/docs\/article\/how-to-use-offline-google-analytics-in-pwa\/","title":{"rendered":"How to use Offline Google Analytics in PWA"},"content":{"rendered":"\n<p>So you&#8217;ve got a progressive web app, complete with a service worker that allows it to work offline. You&#8217;ve also got existing Google Analytics set up for your web app, and you don&#8217;t want to miss out on any analytical insights coming from usage that occurs while offline.<\/p>\n\n\n\n<p>But if you try to send data to Google Analytics while offline, those requests will fail and the data will be lost. It&#8217;s adding code to your service worker to store Google Analytics requests and retry them later when there&#8217;s hopefully a network available. <\/p>\n\n\n\n<p>For the solution of this situation we created an option as follows:<\/p>\n\n\n\n<p>You will find this option in the <strong>WordPress Dashboard<\/strong>\u00a0-> Navigate to\u00a0<strong>PWA<\/strong>\u00a0->\u00a0<strong>Settings<\/strong>\u00a0->\u00a0<strong>Advance\u00a0<\/strong>-> Check this &#8220;<strong>Offline Google Analytics<\/strong>&#8221; option and then click on the &#8220;<strong>Save Setting<\/strong>&#8221; button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"395\" src=\"https:\/\/pwa-for-wp.com\/docs\/wp-content\/uploads\/2019\/11\/3-1024x395.png\" alt=\"\" class=\"wp-image-715\" srcset=\"https:\/\/pwa-for-wp.com\/docs\/wp-content\/uploads\/2019\/11\/3-1024x395.png 1024w, https:\/\/pwa-for-wp.com\/docs\/wp-content\/uploads\/2019\/11\/3-300x116.png 300w, https:\/\/pwa-for-wp.com\/docs\/wp-content\/uploads\/2019\/11\/3-768x296.png 768w, https:\/\/pwa-for-wp.com\/docs\/wp-content\/uploads\/2019\/11\/3-50x19.png 50w, https:\/\/pwa-for-wp.com\/docs\/wp-content\/uploads\/2019\/11\/3-60x23.png 60w, https:\/\/pwa-for-wp.com\/docs\/wp-content\/uploads\/2019\/11\/3-100x39.png 100w, https:\/\/pwa-for-wp.com\/docs\/wp-content\/uploads\/2019\/11\/3.png 1050w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Offline Google Analytics:<\/strong> Offline analytics is a module that will use background sync to ensure that requests to Google Analytics are made regardless of the current network condition.<\/li><\/ul>\n\n\n\n<p><strong>That\u2019s it for this tutorial!<\/strong><\/p>\n\n\n\n<p>We hope we\u2019ve clear your doubts in case If you have any feedback or questions, Just contact us&nbsp;<strong>here and<\/strong>&nbsp;we are always available for you.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So you&#8217;ve got a progressive web app, complete with a service worker that allows it to work offline. You&#8217;ve also got existing Google Analytics set up for your web app, and you don&#8217;t want to miss out on any analytical insights coming from usage that occurs while offline. But if&#8230;<\/p>\n","protected":false},"author":3,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[6],"ht-kb-tag":[],"class_list":["post-714","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-how-to"],"_links":{"self":[{"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/ht-kb\/714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/comments?post=714"}],"version-history":[{"count":4,"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/ht-kb\/714\/revisions"}],"predecessor-version":[{"id":719,"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/ht-kb\/714\/revisions\/719"}],"wp:attachment":[{"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/media?parent=714"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=714"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/pwa-for-wp.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}