Capture client-side behavior with JavaScript SDK

With the Sitefinity Insight JavaScript SDK, you can easily track client-side interactions of your website visitors. You can also use the SDK to:

  • Personalize the experience of visitors
  • Check whether visitors are associated with a certain persona
  • Check whether visitors scored points as leads
  • Check whether visitors are targeted by a particular campaign in Sitefinity Insight

Get the JavaScript SDK

To get and install the JavaScript SDK, refer it via CDN:

Link
Minified Minified version 3.0.10
Development Development version 3.0.10

Initialize the JavaScript SDK

After you refer the JavaSscript SDK in your HTML file, you can instantiate an instance of it using the following code:

The SDK client is instantiated by providing a settings object that can contain the following properties:

Name Required Data type  Description 
apiKey Yes  GUID  The API key of the data center you want to report data to.
source Yes String  The name of the data source to which to report  data.

RECOMMENDATION: We recommend using a single data source for all data within a data center in most cases.

For more information, see Data sources.

authToken No  String  The authorization token that is used for authentication. You can use both bearer and authorized application tokens. For more information, see Authorization.
apiServerUrl No String The URL of Sitefinity Insight API server, to which data is reported. 
subjectCookieName No String The name of the cookie the JavaScript SDK uses for tracking visitor behavior. For more information, see Manage cookies.

NOTE: If you are working with JavaScript SDK version 3.0 and newer, the name of the cookie is always set to sf-data-intel-subject and you cannot change it.

trackingCookieDomain No String The cookie domain. For more information, see Manage cookies.
autoTracking No Boolean A flag that can be used to stop the SDK's automatic tracking of visits, which is turned on by default. For more information, see Manage automatic tracking of visits.
instrument No  Boolean Used for enabling the HTML5 instrumentation tracking. For more information, see Enable HTML5 attribute instrumentation.
trackPageVisits No Object Used for providing custom attributes to the default page tracker. For more information, see Track pages.
trackUtmParameters No Object Comprises the settings for tracking of Google Analytics UTM parameters. For more information, see Track Google Analytics UTM parameters.
enableTracking No Boolean

By default, the value of the property is set to true. If you disable this property, no requests are made to the Sitefinity Insight API and no tracking and personalization are executed by the SDK. In accordance with GDPR, the visitor provides consent to be tracked or rejects to be tracked. You set the property value to true or false, accordingly.

For more information, see GDPR compliance.

NOTE: You can work with this parameter only if you are working with JavaScript SDK version 3.0 and newer.


Was this article helpful?