Methods available on the ROI Tracking javascript object Mxm.Tracker
track
Mxm.Tracker.track( )Fundamental method to track a recipient on a page of your website.
Used if autoTrack is disabled, and/or if you have defined a new revenue value using setRevenue and wish to send the new value back to the system.
Return
No return value.
complete
Mxm.Tracker.complete( {string} reference )Called in place of track to track the recipient and mark their transaction as complete.
reference
Optional but highly recommended.
String to identify the transaction. Must be unique (eg. an order ID).
RecommendedThis allows Maxemail to differentiate multiple calls to this method as different transactions. Transactions with the same reference for the same ROI Code will be ignored. If this value is not supplied, only unique conversions will be recorded for an email campaign.
Returns
No return value.
setAutoTrack
Mxm.Tracker.setAutoTrack( {boolean} enabled )Control whether autoTrack is enabled.
Disabled by default.
When enabled, the script will automatically call track when the page has loaded.
Recomendation
autoTrackis not required in most implementations so should be disabled, as most are only concerned with revenue and conversion figures against an email campaign.Using
autoTrackor track to track every page only provides the data to be able to download a tracking log in Maxemail. This can be better handled by tools such as Google Analytics.
Called during initMust be called as part of the script configuration, before the page has loaded.
enabled
A boolean value to enable/disable autoTrack
Returns
Mxm.Tracker for chaining.
setRevenue
Mxm.Tracker.setRevenue( {number} val )Set a revenue value.
Set revenue before trackingRevenue should be defined before a call to track or complete (or before page load if
autoTrackis enabled).
val
Revenue value as an integer. No currency symbols or decimal points are allowed.
Example
// To represent a currency value of £200.00`
Mxm.Tracker.setRevenue(20000);Returns
Mxm.Tracker for chaining.
setRevenueEl
Mxm.Tracker.setRevenueEl( {HTMLElement|string} el )Define the HTML element which contains the transaction revenue value.
The value in the element will be used only if the value has not been set explicitly by setRevenue
Set revenue before trackingRevenue should be defined before a call to track or complete (or before page load if
autoTrackis enabled).
el
HTMLElement object or element ID as string.
At the point of calling track or complete the script will read the numerical values from the inner-HTML of this element, to define the revenue value.
Returns
Mxm.Tracker for chaining.
setAutoLink
Mxm.Tracker.setAutoLink( {boolean} enabled )Control whether autoLink is enabled for cross-site tracking. Used in conjunction with setAutoLinkDomains
Enabled by default.
When enabled, the script will automatically apply a click listener to anchor tags, and a submit handler to forms when the page loads.
Individual links and forms can be marked for cross-site tracking by calling addLink and addForm respectively.
Called during initMust be called as part of the script configuration, before the page has loaded.
enabled
A boolean value to enable/disable autoLink
Returns
Mxm.Tracker for chaining.
setAutoLinkDomains
Mxm.Tracker.setAutoLinkDomains( {string[]} domains )Used to control when cross-site tracking is implemented for links and forms.
domains
An array of strings.
When the user clicks on a link or form that is being monitored via autoLink, addLink or addForm, the target URL's hostname is checked for an exact match to one of these domains before adding the ROI code to the URL's query string.
Returns
Mxm.Tracker for chaining.
addLink
Mxm.Tracker.addLink( {HTMLElement} el )Add cross-site ROI Tracking for a link.
The script will add a click listener to the link, and add the ROI code to the URL's query string, based on the domains supplied via setAutoLinkDomains.
el
The HTML element object for an anchor tag: <A>
Returns
Mxm.Tracker for chaining.
addForm
Mxm.Tracker.addForm( {HTMLElement} el )Add cross-site ROI Tracking for a form.
The script will add a submit handler to the form, and add the ROI code to the action URL's query string, based on the domains supplied via setAutoLinkDomains.
el
The HTML element object for a form tag: <FORM>
Returns
Mxm.Tracker for chaining.
getQueryKey
Mxm.Tracker.getQueryKey( )If unable to use autoLink, addLink or addForm the ROI Code can be manually added to any URLs by building it from the results of getQueryKey and getRoiCode.
Returns
The ROI code query string key, eg. mxmroi
getRoiCode
Mxm.Tracker.getRoiCode( )If unable to use autoLink, addLink or addForm the ROI Code can be manually added to any URLs by building it from the results of getQueryKey and getRoiCode.
Returns
The ROI code query string value, eg. 1-1-1-0
setExpiryDays
Mxm.Tracker.setExpiryDays( {Number} days )Set the recipient identification lifetime.
Default value 45 days.
The recipient's ROI code is stored in the browser's LocalStorage, so if they revisit the site following clicking through from an email, and make a purchase, it will be logged against the clicked email campaign.
Must be called as part of the script configuration, before the page has loaded
days
The number of days before the recipient identification expires
Returns
No return value.
