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.
A call to
hideConsentBanner hides the Consent banner element.