Capture client-side behavior with JavaScript SDK
Overview
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
To create and initialize a new instance of Sitefinity Insight SDK client, in the HTML of your page perform the following:
Register an initialization callback
In the <head> tag of your page, add a <script> tag containing the code to create an instance of the Insight SDK client using the following sample:
function initInsight() {
var insightClient = new sfDataIntell.Client({
apiKey: '12345678-1234-1234-1234-1234567890ab', // replace with your Insight data center API key
apiServerUrl: 'https://api.insight.sitefinity.com', // change this to the API server URL where your Insight account is hosted
source: 'Website',
trackPageVisits: true,
trackBrowserInformation: true,
trackUtmParameters: true,
crossDomainTrackingEntries: ["example.org", "example.com"],
sessionLengthInMinutes: 30,
trackYouTubeVideos: true,
trackVimeoVideos: true
});
}
document.addEventListener('insight-sdk-ready', initInsight);
Optionally, you can provide 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.
For more information, see Data sources. |
apiServerUrl | No | String |
The URL of Sitefinity Insight API server, to which data is reported. The default is the US API server. To learn all available deployment options, see Sitefinity Insight deployment options » Sitefinity CMS and Sitefinity Insight deployments. |
trackingCookieDomain | No | String |
The cookie domain. For more information, see Manage cookies. |
instrument | No | Boolean |
Used for enabling the HTML5 instrumentation tracking. For more information, see Track visitor activities using HTML attribute instrumentation. |
trackPageVisits | No | Object |
Used for providing custom attributes to the default page tracker. For more information, see Track pages. |
trackBrowserInformation | No | Boolean | When you set this property to true, Sitefinity Insight adds the following information to the metadata of the visitor’s interaction (the subject):
|
enableTracking | No | Boolean |
By default, the value of the property is set to For more information, see Manage cookies.
|
cookieMaxAgeInDays | No | Number |
Default value:
|
cookieSlidingExpiration
| No | Boolean |
Default value:
|
crossDomainTrackingEntries | No | Array of strings |
List of domain names of sites for which cross-domain tracking of visitors is performed. That is, a single physical user is tracked across all these domains and their visitor journeys are merged into one.
|
sessionLengthInMinutes | No | Number | The amount of time in minutes which defines a session - group of interactions that take place within a given time frame. If the user is inactive for more than the specified number of minutes, next interactions become part of a new session. Otherwise, every time there is an interaction, the expiration time is extended by adding these additional minutes. |
trackYouTubeVideos | No | Boolean |
Enable tracking of YouTube videos. For more information, see Track Interactions with YouTube videos. |
trackVimeoVideos | No | Boolean |
Enable tracking of Vimeo videos. For more information, see Track Interactions with Vimeo videos. |
useSecureCookies | No | Boolean |
Default: |
Start the SDK
After you have registered the callback, download and execute the Insight SDK.
To do this, in the <head> tag, add the following <script> tag:
<script type="text/javascript" src="https://cdn.insight.sitefinity.com/sdk/sitefinity-insight-client.min.3.1.44.js" async></script>