Amplitude Analytics does provide Javascript SDK for Amplitude but how do I implement analytics in a React App where I don't have access to the DOM directly?
The GitHub page suggests to use amplitude.getInstance().logEvent('EVENT_IDENTIFIER_HERE')
but in React I don't have an unique identifier of a component or a event.
The 'EVENT_IDENTIFIER_HERE'
is actually just any arbitrary but unique name(label) for the event that you want to log. So when you check the amplitude dashboard you are able to find events easily.
i.e amplitude.getInstance().logEvent('visitedHomePage')
or
amplitude.getInstance().logEvent('cartButtonClicked')
etc.
furthermore you can pass extra eventData along with the event like so:
amplitude.getInstance().logEvent('cartButtonClicked', itemsInCart)