Cordova Google Analytics Plugin
Last updated
//Replace your app tracking id here
var trackingID="YOUR_APP_TRACKING_ID";
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
console.log('Google analytics is ready now');
window.ga.startTrackerWithId(trackingID);
}window.ga.startTrackerWithId(trackingId, [interval]);window.ga.startTrackerWithId('UA-XXXX-YY', 30);window.ga.trackView(title, campaignUrl, [newSession]);//To track a Screen (PageView):
window.ga.trackView('Screen Title')
//To track a Screen (PageView) w/ campaign details:
window.ga.trackView('Screen Title', 'my-scheme://content/1111?utm_source=google&utm_campaign=my-campaign')
//To track a Screen (PageView) and create a new session:
window.ga.trackView('Screen Title', '', true)window.ga.trackEvent(category, action, [label], [value], [newSession])//To track an Event
window.ga.trackEvent('Videos', 'play', 'Fall Campaign', 42)
//To track an Event and create a new session:
window.ga.trackEvent('Videos', 'play', 'Fall Campaign', 42, true)window.ga.setUserId(id);//user ID for testing purpose
var myUserId="35009a79-1a05-49d7-b876-2b884d0f825b";
window.ga.setUserId(myUserId);window.ga.setAppVersion(appVersion)window.ga.setAppVersion('1.33.7');window.ga.debugMode()window.ga.debugMode();