The React JavaScript SDK can work with Sitecore tracking and analytics via the Headless Proxy. In "headless mode," all requests are proxied through the node instance, which is also doing server-side rendering of your application. This means that the Sitecore Analytics cookie is associated with the domain of the node server.
If you create a custom endpoint for identifying a user, and proxy it through the Headless Proxy, the analytics cookie will be passed and you can successfully identify the user. The included JSS Tracking API works in the same manner.
Some notes about implementing such an API endpoint:
- Be sure to use an MVC Controller and not a Web API. Web APIs do not support session, which is required for Sitecore Analytics.
- Be sure your API path is excluded from rewriting/SSR in your headless proxy configuration.