Packagecom.distriqt.extension.googleanalytics
Classpublic final class GoogleAnalytics
InheritanceGoogleAnalytics Inheritance flash.events.EventDispatcher

This class represents the Google Analytics extension.



Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined By
  
Constructor You should not call this directly, but instead use the singleton access
GoogleAnalytics
  
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
  
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
Public Constants
 ConstantDefined By
  EXT_CONTEXT_ID : String = com.distriqt.GoogleAnalytics
[static]
GoogleAnalytics
  VERSION : String = 4.2.0
[static]
GoogleAnalytics
Property Detail
defaultTrackerproperty
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


Implementation
    public function get defaultTracker():Tracker
implementationproperty 
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:


Implementation
    public function get implementation():String
isSupportedproperty 
isSupported:Boolean  [read-only]

Whether the current device supports the extensions functionality


Implementation
    public static function get isSupported():Boolean
nativeVersionproperty 
nativeVersion:String  [read-only]

The native version string of the native extension.


Implementation
    public function get nativeVersion():String
serviceproperty 
service:GoogleAnalytics  [read-only]

The singleton instance of the GoogleAnalytics class.


Implementation
    public static function get service():GoogleAnalytics

Throws
Error — If there was a problem creating or accessing the extension, or if the key is invalid
versionproperty 
version:String  [read-only]

The version of this extension.

This should be of the format, MAJOR.MINOR.BUILD


Implementation
    public function get version():String
Constructor Detail
GoogleAnalytics()Constructor
public function GoogleAnalytics()

Constructor You should not call this directly, but instead use the singleton access

Method Detail
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.

Returns
Boolean
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"
         

Returns
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

Returns
Tracker
init()method 
public static function init(key:String):void
Deprecated: You no longer need to use an application key

Initialises the extension class for use with the provided key.

Parameters

key:String


Throws
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

Returns
Boolean
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:Booleantrue 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:Booleantrue 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

Constant Detail
EXT_CONTEXT_IDConstant
public static const EXT_CONTEXT_ID:String = com.distriqt.GoogleAnalytics

VERSIONConstant 
public static const VERSION:String = 4.2.0