Giter Site home page Giter Site logo

nuxt3-matomo's Introduction

Nuxt3-Matomo

Tutorial and code to add Matomo to a nuxt 3 project (very easy)

1 add Vue Matomo

in your terminal enter the following command

npm install --save vue-matomo

2 add Nuxt plugin

Add file your-project/plugins/super-matomo-plugin.js to the project with this :

import { defineNuxtPlugin } from '#app'
import VueMatomo from 'vue-matomo'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(VueMatomo, {
    host: 'https://your-matomo-domain-address.com',
    siteId: 1, 
    // Enables automatically registering pageviews on the router
    router: nuxtApp.$router,
    enableLinkTracking: true,
    requireConsent: false,
    trackInitialView: true,
    disableCookies: true,
    requireCookieConsent: false,
  })
})

If you are using Server Side Rendering (SSR) you have to add '.client' in your file name.

exemple : your-project/plugins/super-matomo-plugin.client.ts

3 change the Matomo server address

change the line host: 'https://your-matomo-domain-address.com',

4 register your plugin to your Nuxt app

file nuxt.config.ts

export default ({
    app: {
   head: {
      title: 'Bonjour', 
      htmlAttrs: {
          lang: 'fr'
      },
      meta: [
          { charset: 'utf-8' }
      ]
    }}, 

  plugins: [
    { src: '~/plugins/super-matomo-plugin.js', ssr: false }
  ],

})

That it, your are a boss

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.