How to set up Pirsch Analytics in Nuxt 2
2 min read
You may have your reasons for searching out an alternative to Google Analytics. If you want to get set up with Pirsch Analytics and Nuxt 2, you'll find the process very quick.
- You will need a Nuxt application hosted on a live domain name. It won't work locally.
Step 1. Getting set up with Pirsch
Sign up with Pirsch through https://pirsch.io/ and verify your email.
They'll take you through an onboarding process where you can add your domain name. Make sure to include
www if that's where your naked domain redirects to.
They'll show you a Script tag that you can copy that looks like this:
Step 2. Loading their script in Nuxt
With Nuxt, they use Vue Meta, the HTML Metadata manager for Vue.js. This allows you to inject scripts or stylesheets amongst other things into the header of your SPA, universal or static app.
Add the following script block through the
data-code to match the code from Pirsch.
Step 3. Deploy and wait
Within minutes of deploying, we had cookieless, privacy-first analytics. It took longer to write this article than it took to make the change and get set up with Pirsch 😂.
Disclaimer: Why not Google Analytics?
Firstly, I just have to make sure I'm not mistaken; I have no hatred for Google or for Google Analytics. Yes, the mass data collection is a little creepy, but more importantly for me, I can't stomach the cookie (🍪) bombardment (💣) after GDPR came in. I don't want that experience for users at embodimentshop.com either.