Track visitor activities using HTML attribute instrumentation

The JavaScript SDK supports HTML instrumentation functionality that makes reporting data to Sitefinity Insight on some interactions with the HTML elements on your page easier. For example, you can track clicks on buttons, links, or images on your page, expanding dropdown menus, and so on.

You can use this functionality, for example, to track steps of the visitor’s journey, such as clicking CTAs, clicking links to external sites, or interacting with an important UI element.

If you are using the Sitefinity Insight JavaScript SDK outside of Sitefinity CMS, this functionality is turned off. To enable HTML instrumentation, when instantiating the SDK client, set the constructor's instrument parameter to true.

NOTE: Tracking HTML elements is turned on by default in Sitefinity CMS.

Once enabled, HTML instrumentation detects the following element attributes, which you can then add to any HTML element inside your web pages:

Name Required Description
sfdi-trigger Yes The HTML5 event, on which the JavaScript SDK reports the interaction to Sitefinity Insight.
sfdi-predicate Yes The predicate of the reported interaction.
sfdi-object No The object of the reported interaction.
sfdi-obj-metadata No

The object metadata of the reported interaction. Note that the attribute value must be a stringified object of string properties, for example: '{\"pageTitle\": \"Home Page\", \"pageAuthor\": \"John Smith\"}'.

If no object metadata is provided, the SDK reports just the entire URL of the page, using the location.href property as ReferrerUrl.
sfdi-sub-metadata No The subject metadata of the reported interaction. Note that the attribute value must be a stringified object of string properties, for example: '{\"browser-name\": \"Chrome\", \"os\": \"Windows\"}'

The example below demonstrates how to use HTML instrumentation to report data to Sitefinity Insight when a user clicks on a specific link:

Was this article helpful?