Getting Started with the Tracking and Consent JavaScript API

Before you get started, the Tracking and Consent API must be enabled on the account.

In Account Engagement:

  1. Go to Settings.
  2. Click Edit.
  3. Select Activate the Tracking & Consent JavaScript API.

In the Account Engagement Lightning App:

  1. Select Account Engagement Settings.
  2. Click Edit.
  3. Select Activate the Tracking & Consent JavaScript API.

To get started, add Account Engagement analytics to your site. This snippet adds Account Engagement analytics to your page and records a page view when the library loads. Replace the piDomain with your specific account information. Add the snippet to any page you’d like to collect Account Engagement analytics on.

Set the piDomain to a verified Account Engagement tracker domain in your account. This tracker domain must be a subdomain of the tracked page. For example, adding the snippet to example.com must use a piDomain with the root domain of subdomain.example.com.

The Account Engagement analytics JavaScript library is loaded asynchronously and establishes an empty analytics action queue if one doesn’t exist.

Next, add some analytics actions to be processed after the library has loaded. Create an analytics tracker, and send a page view to Account Engagement. When a visitor views the page, a tracked page view is sent to Account Engagement. If the page visitor is in a geo that requires consent as defined in your Account Engagement account settings and hasn’t yet opted in, the page view isn't recorded. Instead, the consent banner is shown.

Analytics actions are always processed in order after the Account Engagement analytics library has loaded. Additional actions are processed synchronously after the queue has been processed. See Tracking and Consent Functions for additional actions you can take with Account Engagement analytics.