AutoTrack - Automated Event Tracking


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.

Capture des événements automatisés avec Autotrack

What events are tracked by the Autotrack option?

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.

Introduction to "DataSets"

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.

Purpose of DataSets

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 different modes of the AutoTrack option

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.

The "off" mode

In this state, the "Autotrack" option is completely deactivated. There is no automatic capture of events.

The "dataset" mode

In this mode, only those elements with defined datasets are tracked.

The "on" mode

In this mode, all events are tracked, even if no dataset is defined.

AutoTrack sub-settings.

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:
  • Off mode: Deactivates completely
  • Dataset mode: Tracks only if the "dataset" is defined.
  • On mode: Tracks all events.

  • 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');
    

    "Video" setting

    Change the video tracking mode.
    
    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".

    "Download" setting

    Change the tracking mode of downloads.
    
    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".

    "Outboundclick" setting

    Change the tracking mode of "Exit clicks"
    
    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".

    "Insideclick" setting

    Change the tracking mode for clicks targeted to a site page.
    
    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".

    "Iframe" setting

    Change the tracking mode of "iframe" elements.
    
    aa('set',"autotrack.iframe","off");
    

    "Div" setting

    Change the tracking mode for "div" elements.
    
    aa('set',"autotrack.div","off");
    

    "Button" setting

    Change the tracking mode for "button" elements.
    
    aa('set',"autotrack.button","off");
    

    Example of the setting of several options with a single line of code:

    
    aa('set',"autotrack","dataset");
    aa('set',"autotrack",{"insideclick":"on","iframe":"off"});
    

    Setting the datasets attributes for the Autotrack option

    The syntax of a dataset defined for autotrack is as follows:
    
    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'
    

    The different "dataset" fields available:

    The "hitType" field (optional)

    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” field

    This field indicates the category of the event: click, download, form, video, window, alert and navigation

    The "action" field

    This 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" field

    This field specifies the type of the event. Not to be confused with hitType.

    The "url" field

    This field specifies the destination of the event.

    The "callback" field

    This field specifies a callback function.

    The "params" field

    This field specifies a string to be passed to the return function.

    List of examples of using the AutoTrack feature

    Tracking clicks with autotrack and datasets

    
    <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.

    Tracking the downloads with autotrack and 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.

    Tracking the playback of a YouTube video with Autotrack and dataset.

    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>
    

    Conclusion

    Used wisely, the AutoTrack feature allows you to track all the interactions between the visitors and the website pages without any line of code.



     
    By AFS Website Analytics

    Go Top
    AFS Analytics uses LiveDisplay Tachnology