Google Analytics for Titanium applications.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

TitaniumAnalytics Module

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(""),
	tracker = Analytics.getTracker('UA-XXXXXXX-X');


If you are building the Android module, make sure you update the .classpath and files to match your setup.

Module Reference


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.

Analytics.createTransaction(transactionId, transactionOptions);

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)


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.

Tracker Reference


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)


  • exceptionOptions (Object):
    • An object containing the following:
      • fatal (Boolean)
      • description (String)


  • socialOptions (Object):
    • An object containing the following:
      • social (String)
      • action (String)
      • target (String)


  • timingOptions (Object):
    • An object containing the following:
      • category (String)
      • interval (Integer)
      • name (String)
      • label (String)


  • 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.


  • useHttps (Boolean):
    • If set to true hits will be sent over the HTTPS protocol. This defaults to true.


  • sampleRate (Float):
    • This will limit the number of hits sent to Google Analytics. It can range from 0 to 100. This is useful if your application has a large number of users.


  • 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.

Transaction Reference


  • 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)