Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics not tracking events in HTML5 mobile app properly on iPhones

We are using Google Analytics to track events, but events don't appear to track 100% of the time. Sometimes they track, and sometimes they don't. We're not exceeding quota limits per session (at most we have 20 events per session). That shouldn't be the issue.

The tracking fails to work consistently on our normal website as well as our HTML5 mobile app version, though it's far less reliable with the HTML5 mobile app version.

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' );
}
like image 309
Crashalot Avatar asked Feb 15 '23 23:02

Crashalot


2 Answers

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

This won't do anything.

For _trackEvent, the third argument (where you pass an empty string) is required. It's the 'Action' parameter. But an empty string is falsey, so it just fails silently.

Pass any value there, and it'll work.

Is this a reduced case? You shouldn't be seeing any events with that code.

like image 153
Yahel Avatar answered Feb 18 '23 13:02

Yahel


Are you positive that you waited long enough for the data to be processed by Google? Especially since some tracking seems to be working. I had the same behaviour (in a mobile app btw) but after waiting for more than a day it still came through. This still occurs on a daily basis... Hope this is the case for you too.

like image 44
tafh Avatar answered Feb 18 '23 13:02

tafh