Track events in JSS apps using the Tracking API
Version:
You can use the JSS Tracking API to track events, goals, outcomes, campaigns, and page/route views.
To track events in a JSS page or component:
-
Configure the Tracking API, providing the Sitecore API host and the Sitecore API key:
-
To track a simple event, call the
trackEventmethod of the JSS Tracking API with a parameter of the typeEventInstance. For example, to track the click of a Download button:The
trackEventmethod accepts an array of events. For example, to track the click of a button and a page view, you can add the page view event to the array: