Chord OMS
...
Gatsby
SDK Reference

useAnalytics

11min

The useAnalytics hook returns a series of methods that fire a tracking event to Segment, our integrated customer data platform.

Most Segment tracking is done automatically by the SDK. For example, when you use the addToCart method (see useCart), a corresponding track API call to Segment is made. However, some track calls need to be closely tied to the UI, as in the case of tracking clicks on elements, and these calls need to be explicitly made from your React components. Methods for making these calls are available via the useAnalytics hook and listed below.

trackCartViewed()

Results in a Cart Viewed trackevent in Segment.

Example:

trackCollectionClicked()

Results in a Collection Clicked track event in Segment.

Example:

trackEmailCaptured()

Results in a Email Captured track event in Segment.

Example:

trackProductClicked()

Results in a Product Clicked track event in Segment.

Example:

trackProductListFiltered()

Results in a Product List Filtered track event in Segment.

Example:

trackProductListViewed()

Results in a Product List Viewed track event in Segment.

Example:

trackProductViewed()

Results in a Product Viewed track event in Segment.

Example:

trackPromotionClicked()

Results in a Promotion Clicked track event in Segment.

Example:

trackPromotionViewed()

Results in a Promotion Viewed track event in Segment.

Example:

trackStockRequestCreated()

Results in a Stock Request Created track event in Segment.

Example:



Updated 03 Mar 2023
Did this page help you?