Package | com.distriqt.extension.googleanalytics |
Class | public final class GoogleAnalytics |
Inheritance | GoogleAnalytics ![]() |
This class represents the Google Analytics extension.
Property | Defined By | ||
---|---|---|---|
defaultTracker : Tracker [read-only]
Returns the default tracker. | GoogleAnalytics | ||
implementation : String [read-only]
The implementation currently in use. | GoogleAnalytics | ||
isSupported : Boolean [static] [read-only]
Whether the current device supports the extensions functionality
| GoogleAnalytics | ||
nativeVersion : String [read-only]
The native version string of the native extension. | GoogleAnalytics | ||
service : GoogleAnalytics [static] [read-only]
The singleton instance of the GoogleAnalytics class. | GoogleAnalytics | ||
version : String [read-only]
The version of this extension. | GoogleAnalytics |
Method | Defined By | ||
---|---|---|---|
Constructor
You should not call this directly, but instead use the singleton access
| GoogleAnalytics | ||
dispatchLocalHits():void
Dispatches hits queued in the application store (views, events,
or transactions) to Google Analytics if a network connection is
available. | GoogleAnalytics | ||
dispose():void
Disposes the extension and releases any allocated resources. | GoogleAnalytics | ||
getAppOptOut():Boolean
Returns whether the state of the application-level opt is on. | GoogleAnalytics | ||
getInstallReferrer():String
Android only
Retrieves the install referrer to see which campaigns, websites,
and other apps are referring users to Google Play Store to
download your app. | GoogleAnalytics | ||
getTracker(trackingID:String):Tracker
Creates or gets a tracker from the specified tracking ID. | GoogleAnalytics | ||
init(key:String):void Deprecated: You no longer need to use an application key [static]
Initialises the extension class for use with the provided key. | GoogleAnalytics | ||
isDryRunEnabled():Boolean
Returns whether dry run mode is on
| GoogleAnalytics | ||
setAppOptOut(optOut:Boolean):void
Sets or resets the application-level opt out flag. | GoogleAnalytics | ||
setDryRun(dryRun:Boolean):void
Toggles dry run mode. | GoogleAnalytics | ||
setLocalDispatchPeriod(seconds:int):void
Sets dispatch period for the local dispatcher. | GoogleAnalytics |
Constant | Defined By | ||
---|---|---|---|
EXT_CONTEXT_ID : String = com.distriqt.GoogleAnalytics [static] | GoogleAnalytics | ||
VERSION : String = 4.2.0 [static] | GoogleAnalytics |
defaultTracker | property |
defaultTracker:Tracker
[read-only]
Returns the default tracker. This will be the first tracker that you created
Note: This may be null if you haven't created any trackers
public function get defaultTracker():Tracker
implementation | property |
implementation:String
[read-only]
The implementation currently in use. This should be one of the following depending on the platform in use and the functionality supported by this extension:
Android
iOS
default
unknown
public function get implementation():String
isSupported | property |
isSupported:Boolean
[read-only] Whether the current device supports the extensions functionality
public static function get isSupported():Boolean
nativeVersion | property |
nativeVersion:String
[read-only]
The native version string of the native extension.
public function get nativeVersion():String
service | property |
service:GoogleAnalytics
[read-only] The singleton instance of the GoogleAnalytics class.
public static function get service():GoogleAnalytics
Error — If there was a problem creating or accessing the extension, or if the key is invalid
|
version | property |
version:String
[read-only]
The version of this extension.
This should be of the format, MAJOR.MINOR.BUILD
public function get version():String
GoogleAnalytics | () | Constructor |
public function GoogleAnalytics()
Constructor You should not call this directly, but instead use the singleton access
dispatchLocalHits | () | method |
public function dispatchLocalHits():void
Dispatches hits queued in the application store (views, events, or transactions) to Google Analytics if a network connection is available.
This method only works when Google Play service is not available on the device and local dispatching is used. In general, applications should not rely on the ability to dispatch hits manually.
dispose | () | method |
public function dispose():void
Disposes the extension and releases any allocated resources. Once this function
has been called, a call to init
is neccesary again before any of the
extensions functionality will work.
getAppOptOut | () | method |
public function getAppOptOut():Boolean
Returns whether the state of the application-level opt is on.
ReturnsBoolean |
getInstallReferrer | () | method |
public function getInstallReferrer():String
Android only
Retrieves the install referrer to see which campaigns, websites, and other apps are referring users to Google Play Store to download your app.
You will need some manifest additions for this function so make sure you have the following in your manifest
<service android:name="com.google.android.gms.analytics.CampaignTrackingService"/> <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver" android:exported="true" android:permission="android.permission.INSTALL_PACKAGES"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> <receiver android:name="com.distriqt.extension.googleanalytics.InstallReferrerReceiver"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver>
Testing the install referrer.
You can use the following adb commands to test the referrer,
just make sure to replace air.com.distriqt.test
with the package of your application.
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n air.com.distriqt.test/com.distriqt.extension.googleanalytics.InstallReferrerReceiver --es "referrer" "utm_source=test_source\&utm_medium=test_medium\&utm_term=test_term\&utm_content=test_content\&utm_campaign=test_name"
String — The install referrer string
|
getTracker | () | method |
public function getTracker(trackingID:String):Tracker
Creates or gets a tracker from the specified tracking ID.
Parameters
trackingID:String |
Tracker |
init | () | method |
public static function init(key:String):void
Initialises the extension class for use with the provided key.
Parameters
key:String |
Error — If there was a problem creating or accessing the extension, or if the key is invalid
|
isDryRunEnabled | () | method |
public function isDryRunEnabled():Boolean
Returns whether dry run mode is on
ReturnsBoolean |
setAppOptOut | () | method |
public function setAppOptOut(optOut:Boolean):void
Sets or resets the application-level opt out flag. If set, no hits will be sent to Google Analytics. The value of this flag will not persist across application starts. The correct value should thus be set in application initialization code
Parameters
optOut:Boolean — true if application-level opt out should be enforced
|
setDryRun | () | method |
public function setDryRun(dryRun:Boolean):void
Toggles dry run mode.
In dry run mode, the normal code paths are executed locally, but hits are not sent to Google Analytics servers. This is useful for debugging calls to the Google Analytics SDK without polluting recorded data.
By default, this flag is disabled
Parameters
dryRun:Boolean — true if dry run mode should be enabled
|
setLocalDispatchPeriod | () | method |
public function setLocalDispatchPeriod(seconds:int):void
Sets dispatch period for the local dispatcher.
The dispatcher will check for hits to dispatch every dispatchPeriod seconds.
If zero or a negative dispatch period is given, automatic dispatch
will be disabled, and the application will need to dispatch events
manually using dispatchLocalHits()
. This method only
works if local dispatching is in use. Local dispatching is only
used in the absence of Google Play services on the device.
In general, applications should not rely on the ability to dispatch
hits manually
Parameters
seconds:int — The new dispatch period in seconds
|
EXT_CONTEXT_ID | Constant |
public static const EXT_CONTEXT_ID:String = com.distriqt.GoogleAnalytics
VERSION | Constant |
public static const VERSION:String = 4.2.0