AFS Analytics offers an option to automatically track the interactions between visitors and the pages of a website. This feature, named AutoTrack, is undoubtedly a major asset of this web analytics solution.
The Autotrack option tracks the clicks associated with links, HTML elements and iframes present in a web page. Once detected, the element associated with the click is analyzed in order to define its attributes and the triggered action. It can be downloading a file, viewing a video, opening a window, submitting a form or simply clicking on a link.
Sending a page view can also be triggered by the autotrack option. This provides a detailed report about the most viewed sections of single-page websites.
Autotrack automatically detects the characteristics of an event, but specifying attributes via datasets increases the accuracy and effectiveness of this feature.
HTML5 enables the association of an HTML element with data by using the data- attribute called dataset. To use this feature, your HTML page must be HTML5 compliant, that is, it must include the HTML5 doctype: <!DOCTYPE html>.
The syntax of a dataSet consists of the name of the variable preceded by the prefix data- followed by its value placed in a string.
<element data-category = "value"> ... </ element>
In our example, the dataset is category and its value is value.
The purpose of datasets is the simplification of the storage of data in HTML documents, especially in the elements. Thanks to the dataSets, you can supply autotrack with a lot of data about the properties of an event.
The AutoTrack option accepts three different modes. The desired mode is transmitted with the set command via the aa() function. This setting must follow the creation of the tracker.
AFS Analytics allows you to disable some features of AutoTrack. This is useful if you do not want to track certain events or items.
Note: These settings must be made after specifying the main mode of autotrack. Otherwise, they will be ignored.
Three modes are available for sub-settings:To set a sub-setting, we add a dot to "autotrack" followed by the sub-setting name .
aa ('set','autotrack.subsetting',[state]);
//Track only outbound click
aa ('set','autotrack','off');
aa ('set','autotrack.outboundclick','on');
//but not into the "iframe"
aa ('set','autotrack.iframe','off');
Note: There is a hierarchy in the definition of sub-settings. You must first set the general autotrack setting, then second the sub-settings insideclicks, outboundclick, download,video and lastly the sub-settings of the elements. iframe, div, et button.
//first setting
aa ('set','autotrack','on');
//disable inside clicks (second setting)
aa ('set','autotrack.insideclick','off');
//disable iframe tracking (last setting)
aa ('set','autotrack.iframe','off');
aa('set',"autotrack.video","off");
//same thing with a object
aa('set',"autotrack",{"video”:"off"});
Note: The "iframe" sub-setting takes the value of the video sub-setting if "iframe" is set to "off".
aa('set',"autotrack.download","off");
The "iframe", "div" and "button" sub-settings take the value of the "download" sub-setting if they are set to "off".
aa('set',"autotrack.outboundclick","off");
The "iframe", "div" and "button" sub-settings take the value of the "outboundclick" sub-setting if they are set to "off".
aa('set',"autotrack.insideclick","off");
The "iframe", "div" and "button" sub-settings take the value of the "insideclick" sub-setting if they are set to "off".
aa('set',"autotrack.iframe","off");
aa('set',"autotrack.div","off");
aa('set',"autotrack.button","off");
aa('set',"autotrack","dataset");
aa('set',"autotrack",{"insideclick":"on","iframe":"off"});
data-[datasetprefix]-[name of the field to be filled in]='field value'
Note:datasetprefix is a variable defined with the default value aa.
Example for category field:
Data-aa-category = 'click'
This field specifies the type of hit. It can accept two values: event or pageview. If it is not defined, it will be configured with event.
The "label" field (required)This field specifies the title of the event.
Note: If the hitType is pageview, the label field can be replaced by title.
The “category” fieldThis field indicates the category of the event: click, download, form, video, window, alert and navigation
The "action" fieldThis field specifies the action. For example, for a click: Inside or outbound. For a list of available actions, please refer to the document "Event Tracking"
The "type" fieldThis field specifies the type of the event. Not to be confused with hitType.
The "url" fieldThis field specifies the destination of the event.
The "callback" fieldThis field specifies a callback function.
The "params" fieldThis field specifies a string to be passed to the return function.
<a href="https://www.mysite.com" data-aa-hitType="event" data-aa-category="click" data-aa-label="mygreatclick" >my great click</a>
Note: AFS Analytics will automatically detect the url, type and action fields if they are not defined in the datasets.
<a href="http://monsite.com/monfichier.pdf" data-aa-hitType="event" data-aa-category="download" data-aa-label="mon super fichier pdf" data-aa-callback="mycallback" data-aa-params="{message:'test'}" >monfichier.pdf</a>
Note: The callback function "mycallback" will be called after sending the event to analytics.js. The URL doesn't need to be specified in the dataset, it is already within the a href tag.
The play action can be used as an alternative to the start action.
<iframe src="https://www.youtube.com/embed/cnBtRh08ShQ?rel=0" frameborder="0" data-aa-category='video' data-aa-action='play' data-aa-label='AFS Analytics vidéo'></iframe>
Used wisely, the AutoTrack feature allows you to track all the interactions between the visitors and the website pages without any line of code.