Tracking API allows you to easily set up tracking for custom events or adding any third party providers. The tracking API is included on any Mono website, mobile site, and Facebook Page.
Usage
By default, if reporting is enabled for a site, the tracking API is set up to use Google Analytics and the results are visible in the Reporting > Actions section when logged in to the Mono tool.
Adding your own tracking events
Set up tracking in the following two ways:
- Adding two attributes to the HTML element
- Using JavaScript
1. Using data-track-* attributes
In order to add custom events, one way to set up tracking is to add two attributes to the HTML element you wish to track.
- data-track-event: The first attribute is
data-track-event
and defines the browser event on which to trigger the event. This could beclick
for when a user clicks the element - data-track-action: The second attribute is
data-track-action
and defines the name of the action which by default will be visible in the Reporting > Actions section when logged in to the Mono tool. An example would be:<a data-track-event="click" data-track-action="link_clicked" href="#">Click here</a>
Here the action
link_clicked
will be triggered when a user clicks on the anchor element.
Please note, that any element you wish to track using the data-track-*
attributes must inserted using the HTML module. This is because the element needs to be visible in the DOM tree on DOMDocumentReady
.
2. Using JavaScript
V3
Tracking can also be set up using JavaScript. This allows you to track dynamically generated elements, for example jQuery image slideshows or other custom features used on a site.
The tracking API is available through the _monoTracker
global variable. To add tracking for a specific element the _monoTracker.addObject()
method can be used. An example could be:
var myElement = document.getElementById('myElement');
_monoTracker.addObject(myElement, 'click', 'myElement_clicked');
When the DOM element with the ID of myElement
is clicked, the action myElement_clicked
will be recorded. The action will visible in Reporting > Actions in the Mono tool.
A tracking action can also be triggered manually using the _monoTracker.track()
method. This is useful for using the tracking API in combination with for example jQuery:
$(function () {
$('#myElement').click(function () {
_monoTracker.track('myElement_clicked');
});
});
II and V5
In II and V5 the tracking API is available through the _mtr
global variable. To add tracking for a specific element the _mtr.addObject()
method can be used.
* The above documentation applies to II and V5 as well, while only the global variable name is changed (from _monoTracker
to _mtr
).
Adding your own provider
V3
The Mono tracking API allows you to use your own provider for tracking. To add your own provider use the _monoTracker.addTracker()
method provided by the JavaScript tracking API. This method takes a function as its argument, and this function will be called for all default events and any custom events added (as described in section 2). An example looks like:
_monoTracker.addTracker(function (action) {
alert('Triggered tracking action: ' + action);
});
On every event a alert box will show with a message telling which action was triggered.
A real world example for adding Google Analytics looks like this:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(function () {
_monoTracker.addTracker(function (action) {
_gaq.push(['_trackEvent', action]);
});
});
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
This automatically adds Google Analytics for all elements with tracking set up.
II and V5
To add your own provider in II and V5, use the _mtr.addTracker()
method provided by the JavaScript tracking API.
* The above examples will work in II and II V5 by simply replacing _monoTracker
with _mtr
API reference
HTML API
- data-track-event:
data-track-event
- Apply on the element you wish to track. Takes one or more events as the value. Multiple events must be separated with a space. - data-track-action:
data-track-action
- Apply on the element you wish to track. The value is the name of the action to show in the Reporting > Actions section in the Mono tool.
JavaScript API
V3
All API options are available through the _monoTracker
global variable.
_monoTracker.addObject(element, 'event', 'action')
- Adds an DOM object to be tracked. Supports one or more events by separating them with a space._monoTracker.track('action')
- Trigger a tracking action manually._monoTracker.addTracker(function (action) { ... })
- Add a tracking provider. The method takes a function as its argument with the action as its parameter.
II and V5
In II and V5, all API options are available through the _mtr
global variable.
_mtr.addObject(element, 'event', 'action')
- Adds an DOM object to be tracked. Supports one or more events by separating them with a space._mtr.track('action')
- Trigger a tracking action manually._mtr.addTracker(function (action) { ... })
- Add a tracking provider. The method takes a function as its argument with the action as its parameter.
II and V5 also supports custom tracking actions for these modules: Button, Button 2, Form. The action name can be set in the module settings. The action that has been set on the module will have monouser-
prepended to it.
List of default tracking actions
V3
addthis_email
- AddThis share over email clickaddthis_facebook
- AddThis share on Facebook clickaddthis_tweet
- AddThis share on Twitter clickcarousel_next
- Carousel next slide clickcarousel_prev
- Carousel previous slide clickcomment_submit
- Comment module submitcontact_address
- Contact module address clickcontact_us
- Contact form submitcustom_form
- Custom form submitemail_link
- Email link clickfacebook_comment
- Facebook Comments module: Comment addedfacebook_like
- Facebook Like module: User like addedfacebook_send
- Facebook Send module: Message is sentfooter_social_facebook
- Footer Facebook icon clickfooter_social_googleplus
- Footer Google+ icon clickfooter_social_linkedin
- Footer LinkedIn icon clickfooter_social_twitter
- Footer Twitter icon clickgallery_next
- Gallery next image clickgallery_open
- Gallery overlay open tap (Mobile)gallery_overlay_next
- Gallery overlay next image clickgallery_overlay_open
- Gallery overlay openedgallery_overlay_prev
- Gallery overlay previous image clickgallery_prev
- Gallery previous image clickgoogle_plusone
- Google +1 module: +1 addedphone_link
- Contact module phone clickpinterest_pinit
- Pinterest module clickspotboxwithbutton
- Spot box with button clicktaptocall
- Tap to calltaptoemail
- Tap/click to emailtwitter_tweet
- Twitter module: Tweet posted on Twitter
II and V5
custom_form
- Form module submitcustom_form
- Mailchimp form module submitlink_clicked
- External link clickemail_link
- Email link clickphone_link
- Phone link clickfile_download
- Download link clickmap_interaction
- Map Module clickgallery_overlay_open
- Gallery overlay opengallery_overlay_next
- Gallery overlay next clickgallery_overlay_prev
- Gallery overlay prev clickgallery_next
- Gallery next clickgallery_prev
- Gallery prev clickfacebook_like
- Facebook Like module: User like addedfacebook_send
- Facebook Send module: Message is sentfacebook_comment
- Facebook commenttwitter_tweet
- Twitter tweettwitter_follow
- Twitter followrowgroup_next
- Rowgroup next clickrowgroup_prev
- Rowgroup prev clickdirections_clicked
- Get directions button clickedcomment_send
- Comment module submitblog_next
- Blog next clickblog_prev
- Blog previous clickcatalog_next
- Catalog next clickcatalog_prev
- Catalog previous clickpage_share
- Emailshare form module submitnewsletter_signup
- Email signup form module submitinternal_link_clicked
- Click on an internal link in the sitesocial_link
- Click on a link in the social media modulevideo_play
- Play a video in the video module
Dynamic call tracking number insertion- Call tracking:
V3
To measure customer conversion of a SEM campaign and a landing page, a call tracking number (CTN) can be used to tie phone calls to the specific campaign. This feature will automatically replace the phone number set in global data on the landing page with the CTN in the following modules:
- "Click to call" module
- Contact module
- Combined contact & map module
- Header
- Footer
To replace the regular phone number on the landing page with the campaign-specific CTN, the CTN needs to be included in the URL from the campaign ad (e.g. the Google adword). Make sure that your ad-link to the landing page includes the following parameter: ?mono_ctn=1212121212 Example: If the regular phone number on landingpage.com is 40404040 and you want it to be replaced by the campaign specific call tracking number 123123123 for all visitors clicking the ad-link, then the URL from the ad word campaign should look like this: Landingpage.com?mono_ctn=123123123
II and V5
For II and V5, the use of this feature is not confined to particular modules. All you need to ensure, is that the regular phone number used anywhere on your Mono site, is tied to global data.