28
Views
0
Comments
[Google Analytics Reactive] Google Analytics fails to load in safari only in mobile app
google-analytics-reactive
Reactive icon
Forge asset by Sérgio Sardo
Application Type
Mobile
Service Studio Version
11.54.50 (Build 63188)
Platform Version
11.18.1 (Build 37828)

I am attempting to use Google Analytics in a mobile app. The app needs to be available as a PWA, accessible through Chrome and Safari.

I've tried integrating analytics two different ways:

1. Using the Init action in the Google Analytics Reactive module from the Forge.

2. Using a Javascript action to manually add the analytics script to the DOM an initialize it. 

In both cases, analytics loads fine in Chrome, but in Safari it does not load, both desktop and mobile. I see the following error messages:

I know that Safari has a feature "Advanced tracking and fingerprinting protection", which should block google analytics. However I am seeing this error even when that setting is off, and I have confirmed that with other sites analytics loads correctly. When I move the exact same logic from my OutSystems Mobile app into a Reactive Web App, everything works perfectly fine. It's only when running a mobile app as a PWA/website from the Safari browser that it doesn't work.

I'm wondering if this is due to some issue with the service worker interacting weirdly with Safari when it tries to fetch the analytics script.

See the attached example, where you can try to initialize analytics using both methods, in reactive and mobile apps. If you try these in Safari you should be able to see that it always fails with the mobile module, and succeeds with the reactive web module. 



AnalyticsDemoMobile.oml
AnalyticsDemoReactive.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.