0.3.0 • Published 6 years ago

nuxt-piwik v0.3.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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>
0.3.0

6 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago