Using Google Analytics from a Rust Wasm Front-End Web App
medium.com/@matt_78276/using-google-analytics...Posted Feb 21, 2020, 3:35 AM UTC
257
Posted Feb 21, 2020, 3:35 AM UTC
TL;DR: I went on a journey to figure out how to use Google Analytics from Rust front-end Wasm code. On the way I learned how to call JavaScript code from Rust using Wasm-bindgen and made a crate to wrap Google’s gtag.js framework.
Not super familiar with wasm but how do you tell where to load the gtag js script from?
In this case it is expected to be already loaded in as a global JavaScript variable. Google's gtag.js docs have instructions on how to do that. This crate works with those instructions.
Thanks for sharing this. It will help me a lot later.
[deleted]
That's a good point. In this case though, there is already a crate named gtag. I suppose gtag-js could have worked as a name as well. I honestly didn't give it much thought.
I've re-published the crate as
gtag-js. I'm in the process of updating the article.