analytics
analytics copied to clipboard
Usage with Partytown
Has anyone explored using analytics.js with Partytown? It can significantly improve performance by moving third-party analytics tools off the main thread.
It would be cool to run Google Analytics / Facebook Pixel / other tools in Partytown whilst using analytics.js. It looks like it should be possible, but I'm interested to know if anyone has tried it.
somewhat related https://github.com/DavidWells/analytics/issues/46#issuecomment-991750249
People have requested this in the past. https://twitter.com/larsbuur/status/1516788082967822349
I'd love to see if this would work or not. Have at it!
Obviously, one way it can be done is like so:
(assuming you have enabled the experimental feature in your next.config
file):
<Script src="https://unpkg.com/analytics/dist/analytics.min.js" strategy="worker" />
but then you'd opt into automatic versioning and need do a lot of conditional code around the relevant global.