@@ -37,6 +37,11 @@ for(var idx in params) {
3737 }
3838}
3939
40+ if ( embed . enabled ) {
41+ //analytics
42+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'Functionality' , 'Embed Opts' , window . location . search ] ) ;
43+ }
44+
4045$ . ajaxSetup ( { cache : true } ) ;
4146
4247// handle cachin events and display a loading bar
@@ -210,6 +215,8 @@ var positionUpdateHandle = function(position) {
210215 if ( CHASE_enabled ) {
211216 ChaseCar . updatePosition ( callsign , position ) ;
212217 CHASE_timer = ( new Date ( ) ) . getTime ( ) + 15000 ;
218+
219+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'upload' , 'chase car position' ] ) ;
213220 }
214221 }
215222 else { return ; }
@@ -256,9 +263,15 @@ $(window).ready(function() {
256263 if ( e . hasClass ( 'active' ) ) {
257264 e . removeClass ( 'active' ) ;
258265 var h = $ ( '#map' ) . height ( ) + $ ( '#telemetry_graph' ) . height ( ) ;
266+
267+ //analytics
268+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'UI' , 'Telemetry Graph' , 'Collapse' ] ) ;
259269 } else {
260270 e . addClass ( 'active' ) ;
261271 var h = $ ( '#map' ) . height ( ) - $ ( '#telemetry_graph' ) . height ( ) ;
272+
273+ //analytics
274+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'UI' , 'Telemetry Graph' , 'Expand' ] ) ;
262275 }
263276 $ ( '#map' ) . stop ( null , null ) . animate ( { 'height' : h } , function ( ) {
264277 if ( map ) google . maps . event . trigger ( map , 'resize' ) ;
@@ -277,7 +290,12 @@ $(window).ready(function() {
277290
278291 // confirm dialog when launchnig a native map app with coordinates
279292 $ ( '#main' ) . on ( 'click' , '#launch_mapapp' , function ( ) {
280- return confirm ( "Launch your maps app?" ) ;
293+ var answer = confirm ( "Launch your maps app?" ) ;
294+
295+ //analytics
296+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'Functionality' , 'Coord Click' , ( ( answer ) ?"Yes" :"No" ) ] ) ;
297+
298+ return answer ;
281299 } ) ;
282300
283301 // follow vehicle by clicking on data
@@ -331,6 +349,9 @@ $(window).ready(function() {
331349 if ( box . is ( ':hidden' ) ) {
332350 $ ( '#chasecarbox,#aboutbox,#settingsbox,#embedbox' ) . hide ( ) ;
333351 box . show ( ) ;
352+
353+ // analytics
354+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'UI Menubar' , 'Open' , 'Map' ] ) ;
334355 }
335356 checkSize ( ) ;
336357 } )
@@ -340,6 +361,9 @@ $(window).ready(function() {
340361 if ( box . is ( ':hidden' ) ) {
341362 $ ( '.main_screen,#aboutbox,#settingsbox,#embedbox' ) . hide ( ) ;
342363 box . show ( ) . scrollTop ( 0 ) ;
364+
365+ // analytics
366+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'UI Menubar' , 'Open' , 'Chase Car' ] ) ;
343367 }
344368 checkSize ( ) ;
345369 } )
@@ -349,6 +373,9 @@ $(window).ready(function() {
349373 if ( box . is ( ':hidden' ) ) {
350374 $ ( '.main_screen,#chasecarbox,#settingsbox,#embedbox' ) . hide ( ) ;
351375 box . show ( ) . scrollTop ( 0 ) ;
376+
377+ // analytics
378+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'UI Menubar' , 'Open' , 'About' ] ) ;
352379 }
353380 checkSize ( ) ;
354381 } )
@@ -358,6 +385,9 @@ $(window).ready(function() {
358385 if ( box . is ( ':hidden' ) ) {
359386 $ ( '.main_screen,#chasecarbox,#aboutbox,#embedbox' ) . hide ( ) ;
360387 box . show ( ) . scrollTop ( 0 ) ;
388+
389+ // analytics
390+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'UI Menubar' , 'Open' , 'Settings' ] ) ;
361391 }
362392 } )
363393 . on ( 'click' , '.embed' , function ( ) {
@@ -366,6 +396,9 @@ $(window).ready(function() {
366396 if ( box . is ( ':hidden' ) ) {
367397 $ ( '.main_screen,#chasecarbox,#aboutbox,#settingsbox' ) . hide ( ) ;
368398 box . show ( ) . scrollTop ( 0 ) ;
399+
400+ // analytics
401+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'UI Menubar' , 'Open' , 'Embed' ] ) ;
369402 }
370403 checkSize ( ) ;
371404 } ) ;
@@ -386,6 +419,9 @@ $(window).ready(function() {
386419
387420 // blue man reappers :)
388421 if ( currentPosition && currentPosition . marker ) currentPosition . marker . setVisible ( true ) ;
422+
423+ // analytics
424+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'Functionality' , 'Chase Car' , 'Off' ] ) ;
389425 // turning the switch on
390426 } else {
391427 if ( callsign . length < 5 ) { alert ( 'Please enter a valid callsign, at least 5 characters' ) ; return ; }
@@ -406,13 +442,17 @@ $(window).ready(function() {
406442 // if already have a position push it to habitat
407443 if ( GPS_ts ) {
408444 ChaseCar . updatePosition ( callsign , { coords : { latitude : GPS_lat , longitude : GPS_lon , altitude : GPS_alt , speed : GPS_speed } } ) ;
445+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'upload' , 'chase car position' ] ) ;
409446 }
410447
411448 if ( navigator . geolocation ) CHASE_enabled = navigator . geolocation . watchPosition ( positionUpdateHandle , positionUpdateError ) ;
412449 //CHASE_enabled = true;
413450
414451 // hide the blue man
415452 if ( currentPosition && currentPosition . marker ) currentPosition . marker . setVisible ( false ) ;
453+
454+ // analytics
455+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'Functionality' , 'Chase Car' , 'On' ] ) ;
416456 }
417457 } ) ;
418458
@@ -439,10 +479,16 @@ $(window).ready(function() {
439479 e . removeClass ( 'on' ) . addClass ( 'off' ) ;
440480 on = 0 ;
441481 nite . hide ( ) ;
482+
483+ //analytics
484+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'Functionality' , 'Nite Overlay' , 'Off' ] ) ;
442485 } else {
443486 e . removeClass ( 'off' ) . addClass ( 'on' ) ;
444487 on = 1 ;
445488 nite . show ( ) ;
489+
490+ //analytics
491+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'Functionality' , 'Nite Overlay' , 'On' ] ) ;
446492 }
447493
448494 offline . set ( name , on ) ;
@@ -459,9 +505,15 @@ $(window).ready(function() {
459505 if ( e . hasClass ( 'on' ) ) {
460506 e . removeClass ( 'on' ) . addClass ( 'off' ) ;
461507 on = 0 ;
508+
509+ //analytics
510+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'Functionality' , name , 'Off' ] ) ;
462511 } else {
463512 e . removeClass ( 'off' ) . addClass ( 'on' ) ;
464513 on = 1 ;
514+
515+ //analytics
516+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'Functionality' , name , 'On' ] ) ;
465517 }
466518
467519 offline . set ( name , on ) ;
@@ -501,6 +553,9 @@ $(window).ready(function() {
501553 $ ( '.nav .home' ) . click ( ) ;
502554 // pan map to our current location
503555 map . panTo ( new google . maps . LatLng ( currentPosition . lat , currentPosition . lon ) ) ;
556+
557+ //analytics
558+ if ( typeof _gaq == 'object' ) _gaq . push ( [ '_trackEvent' , 'Functionality' , 'Locate me' ] ) ;
504559 } else {
505560 alert ( "No position available" ) ;
506561 }
0 commit comments