Google Analytics does not track events in HTML5 mobile app correctly on iPhone

We use Google Analytics to track events, but events don't seem to track 100% of the time. Sometimes they track, and sometimes not. We do not exceed the quota limit per session (at most, we have 20 events per session). This should not be a problem.

Tracking does not work consistently on our regular website, as well as on our version of the HTML5 mobile application, although it is much less reliable with the version of the HTML5 mobile application.

code:

var share_url = 'http://twitter.com/intent/tweet?text='; // Log in GA _gaq.push( ['_trackEvent', 'Share Twitter', ''] ); // Open URL in browser open_external( share_url + encodeURIComponent( msg ) ); function open_external( url ) { window.open( url + '#phonegap=external' ); } 
+4
source share
4 answers
 _gaq.push( ['_trackEvent', 'Share Twitter', ''] ); 

It will do nothing.

For _trackEvent third argument (where you pass the empty string) is required . This is the action parameter. But the empty string is false, so it just fails.

Pass any value there and it will work.

Is this a reduced case? You should not see any events with this code.

+4
source

Are you sure you have been waiting for data to be processed by Google? Especially since tracking seems to work. I had the same behavior (in the mobile app by the way), but after waiting for more than one day it still passed. This is still happening on a daily basis ... I hope this is the case for you.

+2
source

I'm not quite sure what could be with your problem, so I will give up some idea. Most of them are obvious, but it can help.

On your website:

  • Are you sure you are embedding a piece of Google Analytics code on every page that needs tracking?
  • Download Google analytics from an asynchronous path .
  • In real-time Google analytics> Overview. Since the full report is delayed from a few hours.
  • If you specified something like httq: // localhost /, then you need to add javascript code _gaq.push(['_setDomainName', 'none']); please read this post
  • It cannot work with the file: // url
  • (Maybe not) Check if JavaScript can be downloaded from Google Analytics. Perhaps your proxy blocks Google Analytics tracking?


In your application:

  • You are using the embedded HTML page in your application. Thus, how your open page uses the file: //PATH_TO_MY_DIR/index.html, since you cannot send data to Google Analytics on your hard drive.
  • Since you're probably using PhoneGap, you need to “pop out” of your HTML page into your own Objective-c code and send an event from your Objective-c code. Read google analytics and phonegap and this google group thread


Hope this helps.

+1
source

The problem is the third parameter in:

 _gaq.push( ['_trackEvent', 'Share Twitter', ''] ); 

The second element of the array must be a category, and the third must be an action. For instance:

 _gaq.push( ['_trackEvent', 'Share', 'Twitter'] ); 

You can verify this yourself by pasting each of the above into the developer’s console (F12 in Chrome, Ctrl-Shift-K in Firefox) and viewing network traffic.

Link:

https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEventTracking

+1
source

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


All Articles