And then I got this build error output info WebpackError: TypeError: zaraz.track is not a function. So I want to know how to implement the Zaraz web API functions correctly inside React JS, any suggestions?
Are you using auto-inject? I don’t have a gatsby project nearby to test on but I feel that if you get the error at build time, it may be linked to the auto-inject (which happens at run time, so no zaraz object exists at build time)
Could you try using window.zaraz.track instead? If that does not work, you could maybe have a wrapper in your or that test whether zaraz exists and if not set it to a dumb function like:
zaraz = window.zaraz || { function track() { console.log(Zaraz track called with ${arguments})} };