Cordova Google Analytics Plugin
This Cordova plugin is used to connect to Google's native Universal Analytics SDK.
Plugin ID/package name:
cordova-plugin-google-analyticsTested version: 1.8.6
Demo
Import the Google Analytics plugin demo to your Monaca account

Enable the plugin in the Monaca IDE
From the IDE menu, go to Config → Manage Cordova Plugins .
Click the Import Cordova Plugin button. Then, you can choose to import the plugin using a ZIP file or a URL/package name.
Usage
After importing the plugin to your project, you can start by initializing your tracking ID. Make sure to call the plugin API after the Cordova is loaded.
API references
This section describes some of the main functions used in our demo. For complete API references, please refer to the repository.
startTrackerWithId()
Sets up the analytics tracker.
Parameter
Name
Type
Description
trackingId
String
Your Google Analytics mobile app property
interval
Number
[optional] The dispatch period in seconds (default: 30)
Return Value
Promise
Example
trackView()
Tracks the screen.
Parameter
Name
Type
Description
title
String
Screen title
campaignUrl
String
Campaign url for measuring referrals
newSession
Boolean
[optional] Set to true to create a new session
Return Value
Promise
Example
trackEvent()
Tracks an event.
Parameter
Name
Type
Description
category
String
Event category (e.g. 'Video')
action
String
Action type (e.g. 'play')
label
String
[optional] Event label (e.g. 'Fall Campaign')
value
Number
[optional] A numeric value associated with the event (e.g. 42)
newSession
Boolean
[optional] Set to true to create a new session
Return Value
Promise
Example
setUserId()
Sets a user id.
Parameter
Name
Type
Description
id
String
A unique identifier, associated with a particular user, must be sent with every hit
Return Value
Promise
Example
setAppVersion()
Sets a specific app version.
Parameter
Name
Type
Description
appVersion
String
App version
Return Value
Promise
Example
debugMode()
Enables verbose logging.
Return Value
Promise
Example
Last updated
Was this helpful?