This package has been deprecated

Author message:

WARNING: The package nuxt-piwik is deprecated, please use nuxt-matomo instead

nuxt-piwik

0.3.0 • Public • Published

Piwik for NUXT

npm npm (scoped with tag)

Add Piwik to your nuxt.js application. This plugins automatically sends first page and route change events to piwik

Note: piwik is not enabled in dev mode. You can set environment variable NODE_ENV to production for testing in dev mode.

Setup

  • Install with npm npm install --save nuxt-piwik or use yarn
  • Add nuxt-piwik to modules section of nuxt.config.js
  modules: [
    ['nuxt-piwik', { piwikUrl: '//piwik.example.com/', siteId: 1 }],
  ]

Options

siteId

  • Required

piwikUrl

Url to piwik installation

trackerUrl

Url to piwik.php, default is piwikUrl + 'piwik.php'

scriptUrl

Url to piwik.js, default is piwikUrl + 'piwik.js'

Setting configuration at runtime

You can push any additional tracking info to _paq at runtime by adding a piwik object ```route.meta.piwik`` in the middleware or to the selected pages. An object is used so we can override middleware variables for selected pages

Middleware example:

export default function ({ route, store }) {
  route.meta.piwik = {
    documentTitle: ['setDocumentTitle', 'Some other title'],
    userId: ['setUserId', store.state.userId],
    someVar: ['setCustomVariable', 1, 'VisitorType', 'Member']
  }
}
 

Setting configuration at runtime for selected pages

<template>
  <div>
    <h1 v-if="expVarId === 1">New Content</h1>
    <h1 v-else>Original Content</h1>
  </div>
</template>
<script>
  export default {

    piwik (from, to, store) {
      return {
        someVar: ['setCustomVariable', 1, 'VisitorType', 'Special Member']
      }
    },
    [...]
  }
</script>

Readme

Keywords

none

Package Sidebar

Install

npm i nuxt-piwik

Weekly Downloads

3

Version

0.3.0

License

MIT

Last publish

Collaborators

  • pimlie