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-analytics
Tested version: 1.8.6
To check the third party Cordova plugins, you need to create a custom build debugger (Android version or iOS version).
Demo
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 |
| String | Your Google Analytics mobile app property |
| Number | [optional] The dispatch period in seconds (default: |
Return Value
Promise
Example
trackView()
Tracks the screen.
Parameter
Name | Type | Description |
| String | Screen title |
| String | Campaign url for measuring referrals |
| Boolean | [optional] Set to |
Return Value
Promise
Example
trackEvent()
Tracks an event.
Parameter
Name | Type | Description |
| String | Event category (e.g. 'Video') |
| String | Action type (e.g. 'play') |
| String | [optional] Event label (e.g. 'Fall Campaign') |
| Number | [optional] A numeric value associated with the event (e.g. 42) |
| Boolean | [optional] Set to |
Return Value
Promise
Example
setUserId()
Sets a user id.
Parameter
Name | Type | Description |
| 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 |
| String | App version |
Return Value
Promise
Example
debugMode()
Enables verbose logging.
Return Value
Promise
Example
Last updated