Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google analytics session linking between mobile app and webview

We have a hybrid mobile app (implemented using ReactNative) that incorporates a webview of our website for its ecommerce cart. We have Google Analytics tracking (using the same GA property) in both the app and the website, and ecommerce tracking is enabled on the cart website.

The aim is to have ecommerce tracking (from activity in the webview) work for GA sessions that start on the native app.

Is it possible to enable something like Cross Domain tracking between between the app and the website so that a GA session started by the app will be used by the site within the webview?

like image 312
John Carter Avatar asked Apr 29 '17 21:04

John Carter


People also ask

Can Google Analytics track data from mobile apps?

Use Tag Manager with Google Analytics and Firebase. To get the latest mobile app report features in Google Analytics, use Firebase in your Android and iOS apps. Once enabled in your app, Google Analytics will automatically collect and report on built-in events and user properties.

Can you use Google Analytics for web apps?

First, we're introducing a new property type, App + Web, that allows you to combine app and web data for unified reporting and analysis. Reports for this new property use a single set of consistent metrics and dimensions, making it possible to see integrated reporting across app and web like never before.

Does Google Tag Manager work for mobile apps?

The latest version of Google Tag Manager for mobile apps is smaller, faster, easier to implement, and more functional. It is integrated with Firebase – Google's platform for mobile developers across iOS and Android – and extends its capabilities for developers and marketers.


1 Answers

This scenario isn't supported by the normal GA auto-linker plugin, but it's should be possible to do this manually by extracting the GA session id (clientId) from the session started on the app and passing it to the webview (eg via URL parameters), to set it explicitly as described here: https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain

Google Tag Manager

Note that if you're using Google Tag Manager in the webview, you can set clientId as one of the "Fields to Set" in the UA tag configuration.

You'll also need to define a custom Javascript variable to extract clientId from the URL (or undefined if it's not present or invalid, which means GA will fall back to it's normal behavior).

like image 52
John Carter Avatar answered Sep 27 '22 20:09

John Carter