Events can be sent to DADI Track from applications within the DADI platform or from any website that includes an appropriate script.

DADI Track is deliberately lightweight. It is not intended to be a long term data storage solution or as a replacement for existing tracking tools such as Google Analytics or the wider DADI platform; rather it is designed to facilitate real-time data dashboarding and piping.

Architectural overview

DADI Track is an event tracking server that records user activity using either a tracking pixel built into a website, via a client-side JavaScript library or via an API interface.

The Track server broadcasts received events to any connected clients using Websockets — it is intended that DADI Visualise is one such connected client, and will utilise a collection of widgets to display user activity broadcast by Track.

Tracking

There are currently two forms of tracking available — a tracking pixel and a lightweight client-side JavaScript library.

Tracking pixel

The tracking pixel solution allows the embedding of a one pixel image into your webpages, using the domain of the Track server. Specific events may be captured using the querystring on the request to the tracking pixel:

Additional arbitrary data can be sent along with the request, simply by extending the querystring:

Client-side JavaScript

The JavaScript library contains a small script to trigger a Track event. Once the file is embedded in your webpage(s) the `track()` function can be called:

DADI.track();

Called with no arguments, it will send some standard parameters such as the page URL. As with the tracking pixel approach, you can pass arbitrary data with the event:

DADI.track({logged_in: true});

Event handling via “Metrics”

The Track server loads a collection of “Metrics”, some of which are included in the core, and some which may be custom built and included via a plugin system. Metrics are stored in directories within the Track server and auto-loaded when the server starts.

Each metric contains a handler function that is called every time a new event occurs. Data is stored within the metric and emitted to connected clients at intervals specified by the metric’s own configuration options.

A basic example of a Metric is one for “total page views”. It would look something like this:

// Total views

// Sends total count per interval of time for every request made const Metric = require(‘../metric’).Metric module.exports = function () {

let totalViews = new Metric()

totalViews.name = ‘view_totals’

totalViews.initialData = 0

totalViews.interval = 500

totalViews.ignoreOnEmpty = false

totalViews.increment = function (request) {

this.data += 1

}

return totalViews

}

Visualisation

The alpha build of Track contains a simple dashboard to display events as they are broadcast.