In development...


Installation & Usage

HTML/JavaScript

Add the JavaScript library ma-analytics.min.js to your project (download). A full example is given below in index.html and sample-script.js:

File: index.html

<!DOCTYPE html>
<html>
    <head>
        <!-- Analytics library -->
        <script type="text/javascript" src="ma-analytics.min.js"></script>
        <!-- Developer's custom code -->
        <script type="text/javascript" src="sample-script.js"></script>
    </head>
    <body>
        <!-- Sample button -->
        <input type="button" id="myButton" value="Click me"></input>
    </body>
</html>

File: sample-script.js

// Initialise the MaAnalytics library
var maa = new MaAnalytics({
    tid: "YOUR-TRACKING-ID-HERE"
});

// Log an analytics event on a mouse click
var myButton = document.getElementById("myButton");
myButton.addEventListener("click", function(){
    // Variables to be passed as parameters
    var CATEGORY = "routing to location";
    var ACTION = "click";
    var VALUE = 0;
    var LABEL = "This can be used for supplemental information";
    // Log an event to the MaAnalytics service
    maa.trackEvent(CATEGORY, ACTION, VALUE, LABEL);
});