A full implementation of the Google Analytics SDK for iOS and Android. As of this writing the SDK is at v2.0b4 and v2.0b5 respectively and is not compatible with the legacy application analytics profiles. This implementation supports multiple trackers at the same time so long as all trackers adhere to Google Analytics quotas and limitations on aggregate tracking.
var Analytics = require("com.animecyc.analytics"),
tracker = Analytics.getTracker('UA-XXXXXXX-X');
Analytics.setDebug(true);
tracker.trackScreen('Home');
If you are building the Android module, make sure you update the
.classpath
andbuild.properties
files to match your setup.
Get an instance of a tracker and creates it if it does not exist. Calling getTracker
on
the same UA code will return a reference to the tracker.
- uaCode (String):
- The tracker identifier from a compatible google analytics profile.
Get the default (if not set the first) tracker reference.
This method takes no paramters.
Create a transaction (ECommerce) to be sent via a tracker.
- transactionId (String):
- A unique string identifiing the transaction.
- transactionOptions (Object):
- An object containing the following:
- affiliation (String)
- tax (Float)
- shipping (Float)
- revenue (Float)
- An object containing the following:
Set the debug flag, will result in messages being logged to the console. Ensure you don't leave this enabled for production.
- debug (Boolean):
- Debug status flag
Set the dispatch interval; All hits are queued and will be sent on an interval firing on the interval set by this method. By default queues are dispatched every 120 seconds.
- dispatchInterval (Float):
- Interval at which hits are dispatched automatically.
Track exceptions not caught from the application. Exceptions caught by means of this flag
being set to true
are always reported as fatal.
- trackUncaught (Boolean):
- Boolean flag to catch uncaught exceptions.
If set to true, all trackers will cease to dispatch anything tracked.
- optOut (Boolean):
- Boolean flag to globally opt-out of all analytics tracking.
Track an individual screen, optionally send a screen name with the hit.
- screenName (String):
- String containing the name of the screen being hit.
- eventOptions (Object):
- An object containing the following:
- category (String)
- action (String)
- label (String)
- value (Float)
- An object containing the following:
- exceptionOptions (Object):
- An object containing the following:
- fatal (Boolean)
- description (String)
- An object containing the following:
- socialOptions (Object):
- An object containing the following:
- social (String)
- action (String)
- target (String)
- An object containing the following:
- timingOptions (Object):
- An object containing the following:
- category (String)
- interval (Integer)
- name (String)
- label (String)
- An object containing the following:
- anonymize (Boolean):
- If set to
true
the tracker will anonymize the users session. Typically this will scramble the last octets of a users IP address.
- If set to
- useHttps (Boolean):
- If set to
true
hits will be sent over the HTTPS protocol. This defaults totrue
.
- If set to
- sampleRate (Float):
- This will limit the number of hits sent to Google Analytics. It can range from
0
to100
. This is useful if your application has a large number of users.
- This will limit the number of hits sent to Google Analytics. It can range from
- sessionTimeout (Integer):
- An integer used to set the length of time a session will persist.
- campaignUrl (String):
- A string containing the URL parameters used in analytics campaigns.
- referrerUrl (String):
- A string containing the URL used as a referrer, typically used in a campaign to track where people are coming from.
- tax (Float):
- The tax-rate for the transaction.
- shipping (Float):
- The amount of shipping for the transaction.
- revenue (Float):
- The total revenue for the transaction. This must be updated manually as adding items will not automatically increment this value.
- itemOptions (Object):
- An object containing the following:
- sku (String)
- name (String)
- category (String)
- price (Float)
- quantity (Integer)
- An object containing the following: