简体   繁体   中英

Tracking WebViews into App Profile with Google Analytics

Supposedly, Google Analytics new Universal Analytics, allows Multi-platform tracking. It might be a misunderstanding of the actual location of where data will go. My use case is as follows:

I have a hybrid iOS app. An app with native screens and webview screens. I would like to track both types of screens into the same GA property.

It is my understanding, according to these pages ( https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide and https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#apptracking ) that I should be able to track the webview screens into an "appView" profile. I should also be able to set up the app to track into this property as well.

However, in the process of just setting up the webview to dump into the appView profile, I get no traffic. I am able to see the the request fired via the GA debug Chrome add-on, but see no data in the GA real-time view.

The code I'm injecting is structured as:

<!-- Google Analytics -->
  <script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-12345678-1');
  ga('set', 'appName', 'FOO');
  ga('set', 'appVersion', '0.0.0');
  ga('send', {
    'hitType':'appview'
  });
  </script>
<!-- End Google Analytics -->

The resulting information showing in the JS console from the GA debugger is

adSenseId        (&a)  655544961 
apiVersion      (&v)  1 
appName          (&an)  Foo 
appVersion      (&av)  0.0.0 
clientId        (&cid) 742157966.1379522968 
encoding        (&de)  windows-1252 
flashVersion    (&fl)  11.8 r800 
hitType          (&t)  appview 
javaEnabled      (&je)  1 
language        (&ul)  en-us 
location        (&dl)  http://foo.com/ 
referrer        (&dr)  
screenColors    (&sd)  24-bit 
screenResolution (&sr)  1920x1080 
title            (&dt)  Foo Title
trackingId      (&tid) UA-12345678-1 
viewportSize    (&vp)  387x985 

Which shows the request contains the required item, the hitType (appview, &t) when fired by the analytics.js file.

Am I misunderstanding this usage? Should I only be able to go from the native iOS sdk into the universal tracker? Or is it possible to shoot data from the webview into the universal tracker as an appView?

If it is possible, what is happening to my data?! Were is it going?

Appview tracking with analytics.js didn't work for me neither.

I ended up making plain POST requests to /collect , according to the Measurement Protocol .
(Make sure you have CORS disabled in your ajax library, since Google analytics servers don't like OPTIONS requests)

This way, my webviews (Android PhoneGap App) track to the same GA property as my native iOS App using Google Analytics SDK.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM