nuxt-matomo
Advanced tools
@@ -5,2 +5,13 @@ # Change Log | ||
<a name="1.1.1"></a> | ||
## [1.1.1](https://github.com/pimlie/nuxt-matomo/compare/v1.1.0...v1.1.1) (2019-01-18) | ||
### Bug Fixes | ||
* clear warn mocks ([f1c8549](https://github.com/pimlie/nuxt-matomo/commit/f1c8549)) | ||
* use es6 export ([02e0b70](https://github.com/pimlie/nuxt-matomo/commit/02e0b70)) | ||
<a name="1.1.0"></a> | ||
@@ -7,0 +18,0 @@ # [1.1.0](https://github.com/pimlie/nuxt-matomo/compare/v1.0.0...v1.1.0) (2019-01-07) |
@@ -17,3 +17,3 @@ import { resolve } from 'path' | ||
module.exports = function matomoModule(moduleOptions) { | ||
export default function matomoModule(moduleOptions) { | ||
const options = Object.assign({}, defaults, moduleOptions) | ||
@@ -20,0 +20,0 @@ |
@@ -1,2 +0,1 @@ | ||
import Vue from 'vue' | ||
import { debug, warn, isFn, waitUntil, routeOption } from './utils'<% if(isTest) { %>// eslint-disable-line no-unused-vars<% } %> | ||
@@ -19,3 +18,3 @@ | ||
// inject tracker into context | ||
// inject tracker into app & context | ||
context.$matomo = tracker | ||
@@ -110,3 +109,3 @@ inject('matomo', tracker) | ||
<% } %> | ||
// tell Matomo to add a page view | ||
// tell Matomo to add a page view (doesnt do anything if tracker is disabled) | ||
tracker.trackPageView() | ||
@@ -139,7 +138,7 @@ } | ||
// every time the route changes (fired on initialization too) | ||
router.afterEach(async (to, from) => { | ||
router.afterEach((to, from) => { | ||
const componentOption = routeOption('matomo', tracker, from, to, store) | ||
if (componentOption === false) { | ||
<% if(debug || options.debug) { %> | ||
debug(`Component option returned false, wont track pageview ${to.fullPath}`) | ||
debug(`Component option returned false, wont (automatically) track pageview ${to.fullPath}`) | ||
<% } %> | ||
@@ -165,3 +164,2 @@ return | ||
<% } else { %> | ||
await Vue.nextTick() | ||
trackRoute({ to, componentOption }) | ||
@@ -168,0 +166,0 @@ <% } %> |
{ | ||
"name": "nuxt-matomo", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"license": "MIT", | ||
"description": "nuxt module for matomo analytics", | ||
"description": "Matomo analytics for Nuxt.js", | ||
"repository": "https://github.com/pimlie/nuxt-matomo", | ||
"homepage": "https://github.com/pimlie/nuxt-matomo", | ||
"main": "lib/module.js", | ||
"keywords": [ | ||
"matomo", | ||
"piwik", | ||
"analytics", | ||
"nuxt", | ||
"nuxt.js", | ||
"nuxtjs" | ||
], | ||
"files": [ | ||
@@ -13,4 +21,4 @@ "lib" | ||
"scripts": { | ||
"build": "nuxt build test/fixtures/meta-changed", | ||
"dev": "nuxt test/fixtures/meta-changed", | ||
"build": "nuxt build test/fixtures/basic", | ||
"dev": "nuxt test/fixtures/basic", | ||
"download-matomo": "wget -O test/utils/piwik.js https://raw.githubusercontent.com/matomo-org/matomo/master/js/piwik.js", | ||
@@ -17,0 +25,0 @@ "lint": "yarn lint:lib && yarn lint:matomo", |
@@ -26,10 +26,8 @@ # Matomo analytics for Nuxt.js | ||
### Setting configuration at runtime | ||
By default the document title and `route.fullPath` are tracked. You can add additional tracking info by adding a `route.meta.matomo` object in a middleware or by adding a matomo function or object to your page components. | ||
You can add additional tracking info by adding a `route.meta.matomo` object in a middleware or by adding a matomo function or object to your page components. | ||
The matomo javascript tracker is also injected as `$matomo` in the Nuxt.js context. Use this to e.g. manually track a page view. See the [injected](./test/fixtures/basic/pages/injected.vue) and [manually tracked](./test/fixtures/basic/pages/manuallytracked.vue) pages in the test fixture for an example | ||
> The VueRouter afterEach guard which this plugin uses is called before your page component is created | ||
> See the official [Matomo JavaScript Tracking client docs](https://developer.matomo.org/api-reference/tracking-javascript) for a full overview of available methods | ||
The matomo javascript tracker is also injected as `$matomo` in your Nuxt instance to e.g. manually track a page view. See the [injected](./test/fixtures/basic/pages/injected.vue) and [manually tracked](./test/fixtures/basic/pages/manuallytracked.vue) pages in the test fixture for an example | ||
##### Middleware example | ||
@@ -36,0 +34,0 @@ ```js |
17310
2.93%217
-0.91%196
-1.01%