Javascript API

Refer to the download page for the different types of javascript files that can be downloaded.

Simple API

The simple API is provided in multitouch_simple.js, which comprise the whole of multitouch.js and the wrapper functions multitouch(), multitouch_event() and multitouch_send_event().

multitouch(subcat)

This is a wrapper around MultiTouchTracker.multitouch(). It checks that an instance of MultiTouchTracker has been defined, then invokes MultiTouchTracker.multitouch(subcat).

multitouch_event(tid, rev)

This is a wrapper around MultiTouchTracker.multitouch_event(). It checks that an instance of MultiTouchTracker has been defined, then invokes MultiTouchTracker.multitouch_event(subcat).

multitouch_send_event(tid, rev)

This is simply a wrapper around multitouch_event(), which creates the event data and then sends it using the Google Analytics Asynchronous Tracker.

multitouch_send_event_standard(GoogleID, tid, rev)

This is simply a wrapper around multitouch_event(), which creates the event data and then sends it using the Google Analytics Standard Tracker. GoogleID is the the tracker name, typically of the form "UA-xxxxxx-x".

Full API

MultiTouchTracker()

  var mt = new MultiTouchTracker(params);

Creates the MultiTouchTracker object. Parameters are passed in a Javascript object. Valid parameters are:

cookie_domain
Sets the domain for the cookie. Set this if to your domain name you wish to track touches across multiple subdomains.
cookie_name
Sets the name for the cookie. Defaults to 'multitouch'.
cookie_lifetime
Sets the cookie lifetime, in days. Defaults to 180 days. This is the maximum that the analysis window can be set to.
cookie_size
Many common browsers have size limits on the total size of cookies that they will store; for IE6 and earlier, the size limit is 4096 bytes. This parameter lets you place a limit on the size of the multitouch cookie, in case you have other large cookies and need to ration the available space. This affects the length of history that can be stored. Default is 2048 bytes, which is enough for approximately 100 touches.
allow_internal
Enables storing internal referrals. Useful primarily for testing
fieldsep
The character that separates fields within the cookie; defaults to '!'. Only change this if it conflicts with the names of the source/medium/subcategories that you use.
recsep
Similar to fieldsep, this is the character that separates touch records within the cookie. Defaults to '*'.

MultiTouchTracker.addOrganic()

  mt.addOrganic(newOrganicEngine, newOrganicKeyword, opt_prepend);

This is a direct equivalent of _addOrganic in the Google Tracker API.

MultiTouchTracker.multitouch(subcat)

  mt.addOrganic(newOrganicEngine, newOrganicKeyword, opt_prepend);

Records a touch in the multitouch cookie. Automatically determines the source and medium if the channel is organic, and uses the Google Analytics URL tracking parameters utm_source and utm_medium if present to detect other channels (CPC, email etc). Otherwise treats the touch as a 'direct' entry if there is no referrer, or 'referral' if the referrer is an external referrer. Does nothing if the referrer is from the same domain, unless 'allow_internal' has been set.

The optional 'subcat' parameter is a page-specific tag (unlike source and medium, which record where the visitor has arrived from) which may be set if page or category level analysis is required. When creating reports, a "channel" can be defined as any combination of one or more of 'source', 'medium' and 'subcat'.

MultiTouchTracker.multitouch_event(tid, rev)

  mt.multitouch_event(tid, rev);

Updates the multitouch cookie and returns the event label to be sent to Google Analytics. 'tid' is the transaction ID, 'rev' is the revenue. This should be placed so as to fire once on each transaction, i.e. in the purchase confirmation page. For use with goals other than e-commerce transactions, 'tid' should be set to a unique value (Math.rand() would suffice in most cases) and 'rev' can be set to 0.

For use with Google Analytics Asynchronous Tracker:

   _gaq.push(['_trackEvent','multitouch', 'TID' + tid, mt.multitouch_event(tid, rev) ]);

For use with Google Analytics Standard Tracker:

  var pageTracker = _gat._getTracker("UA-xxxxxx-x");
  pageTracker._trackEvent('multitouch', 'TID' + tid, mt.multitouch_event(tid, rev));

In both cases the 'TID' prefix is important, as event actions must start with an alphabetic character (and the reporting package assumes the prefix is 'TID').