Do redwoodjs community members have or implement an analytics? I’m familiar with mixpanel and Google Analytics. Any recommendations and solutions?
I plan to implement a Cell to return the analytics key from the server-side to the client-side. This way, I can set an environment variable in Netlify to turn on analytics. Any other suggestions on how to implement analytics?
For my last startup (MEAN stack SPA), I used a Segment Analytics.js implementation. (Segment is an aggregator of analytics services – setup up once to use with everything.) You can use their tooling without using their service. Either way you might find their setup instructions really helpful for SPAs:
Oh, that’s a really good point and we’re looking at ways to improve the Router (accessibility being a priority right now). Do you have any more specifics about this, and/or would you be up for creating a new feature request Issue in GitHub about this? I think the more possible examples or ideas about how it could work (even from other existing Router implementations, if applicable) the more likely it is this would get some momentum.
I also needed to add Google Analytics to a Redwood site, and discovered autotrack. It was really straightforward to set up, and handles automatically triggering a GA pageview even when using redwood-router.
There was a link in one of the issues to a repository that does a good job of showing how to set it up.
It would definitely be good to see an “official” recommendation for how to automatically track analytics in a Redwood SPA. I wanted to use Segment or Google Tag Manager, but the information I could find was unhelpful in the context of a SPA.
@bennett thanks for the pointer to autotrack. I play around with it a little bit. It works on page load. But it does not do pageview tracking properly. Page navigation with router does not trigger pageview events.
@thedavid, I found this thread in the react-ga project. One way is to use history listener on react-router. Redwood router does not seem to expose a history listener. We can also wrap components around inside an analytics component.