Install Simple Analytics with Nuxt.js edit

Run this command to install Simple Analytics for Vue:

npm install simple-analytics-vue

Create a file in your plugin folder with the name simple-analytics.js:

// ~/plugins/simple-analytics.js
import SimpleAnalytics from "simple-analytics-vue";
import Vue from "vue";

Vue.use(SimpleAnalytics, { skip: process.env.NODE_ENV !== "production" });

Then on your nuxt.config.js, make sure to include the plugin with ssr: false as we only want to run it on the client:

// nuxt.config.js
export default {
  plugins: [
    { src: '~/plugins/simple-analytics.js', ssr: false }
  ],
}

If you need any additional configuration options (as the ones mentioned above), you just need to apply to your plugin.

If you encounter issues, don’t hesitate to contact us via our support channels.

Special thanks to Joaquim Ley for writing this guide.