Enable HTML5 attribute instrumentation

The JavaScript SDK supports HTML5 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.

By default, this functionality is turned off. To enable HTML5 instrumentation when instantiating the SDK client, set the instrument parameter to true. Once enabled, HTML5 instrumentation detects the following element attributes:

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 HTML5 instrumentation to report data to Sitefinity Insight when a user clicks on a paragraph:

Was this article helpful?