Cordova Google Analytics Plugin
Last updated
Last updated
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).
Import the Google Analytics plugin demo to your Monaca account
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.
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.
This section describes some of the main functions used in our demo. For complete API references, please refer to the repository.
Sets up the analytics tracker.
Parameter
Return Value
Promise
Example
Tracks the screen.
Parameter
Return Value
Promise
Example
Tracks an event.
Parameter
Return Value
Promise
Example
Sets a user id.
Parameter
Return Value
Promise
Example
Sets a specific app version.
Parameter
Return Value
Promise
Example
Enables verbose logging.
Return Value
Promise
Example
Name
Type
Description
trackingId
String
Your Google Analytics mobile app property
interval
Number
[optional] The dispatch period in seconds (default: 30
)
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
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
Name
Type
Description
id
String
A unique identifier, associated with a particular user, must be sent with every hit
Name
Type
Description
appVersion
String
App version