Any possibility to track home button press event in phonegap

1.6k views Asked by At

Hello IS there any event to track Home button press in Android and IOS using phonegap phonegap build.

I search on home button press event but i found only back button events.

2

There are 2 answers

0
mentat On

What about pause event? http://cordova.apache.org/docs/en/4.0.0/cordova_events_events.md.html#pause

You can perhaps track also back button events and exclude them if you really want to count home button clicks..

0
Nurdin On

You can track it using Google Analytic Cordova Plugin.

https://github.com/danwilson/google-analytics-plugin

example

You just call it one time only everytime the app launch.

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    // Now safe to use device APIs
    window.analytics.startTrackerWithId('UA-XXXX-YY')
}

Track screen you need to insert each page that you want to track.

Page 1

window.analytics.trackView('Page 1')

Page 2

window.analytics.trackView('Page 2')

Page 3

window.analytics.trackView('Page 3')

User Id is your user that use your app. You can grab it from your database.

window.analytics.setUserId('1')