When migrating Pages to React, setting up the events with Yext Analytics can be programmatically created. Setting up Yext Analytics is related to the data-y
properties so there isn’t a need for a separate analytics component for each event type.
For example, a client account may have many events in the form filters_<filter-name>
. In the existing pages code, you may see an element with data-ya-scope="filters"
(Image 1) then within that an element with data-ya-track="${filter.displayName}"
(Image 2).
Image 1.
Image 2.
The same structure will be used in React, but the data-ya-scope
is replaced with an AnalyticsScopeProvider and the data-ya-track
is replace with a call to analytics.track(filter.displayName)
which can still take the dynamic filter name.