Tracking and Consent Use Cases and Examples

Use the Tracking and Consent API to accomplish these use cases.

A Single Page Application (SPA) loads all of its navigation resources with the initial page load. As users navigate the site, the page is updated dynamically rather than with traditional page loads. In order to capture page views in an SPA, you must send manual page views to Account Engagement to be recorded.

There are many ways to handle and route requests in SPAs. In this example, there’s a listener that waits for a visitor to click navigation elements that have the navigation-link class. The listener sets the tracked page title to the text of the navigation link, and then sends an analytics request to Account Engagement to record the page view.

If you’re using a third-party consent manager you can sync Account Engagement’s opt in status to match by using the setOptIn analytics action.

Cookie consent laws and regulations vary by region. The Tracking & Consent Javascript API can help ensure that you’re always compliant, while also respecting the privacy of visitors interacting with your content. The consent banner is loaded with HTML from your account’s tracking opt-in preferences. You can display the banner when necessary.

A call to showConsentBanner from the Tracking & Consent JavaScript API resurfaces the consent banner, letting website visitors change their consent preferences. You can use buttons or links on your website to let users reopen the banner.

Calling hideConsentBanner hides the Consent banner element.