nuxt-matomo
Advanced tools
Comparing version
{ | ||
"name": "nuxt-matomo", | ||
"version": "0.5.1", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
@@ -8,10 +8,17 @@ "description": "nuxt module for matomo analytics", | ||
"homepage": "https://github.com/pimlie/nuxt-matomo", | ||
"main": "index.js", | ||
"main": "lib/module.js", | ||
"files": [ | ||
"index.js", | ||
"plugin.js" | ||
"lib" | ||
], | ||
"scripts": { | ||
"lint": "eslint --ext .js,.vue .", | ||
"lint-fix": "eslint --ext .js,.vue --fix" | ||
"build": "nuxt build test/fixture", | ||
"dev": "nuxt test/fixture", | ||
"download-matomo": "wget -O test/fixture/static/piwik.js https://raw.githubusercontent.com/matomo-org/matomo/master/js/piwik.js", | ||
"lint": "yarn lint:lib && yarn lint:matomo", | ||
"lint:lib": "eslint --ext .js,.vue .", | ||
"lint:matomo": "if [ $(node -e \"console.log(require('fs').existsSync('./test/fixture/.nuxt/matomo'));\") = \"false\" ]; then yarn test:fixture; fi && eslint --no-ignore test/fixture/.nuxt/matomo/", | ||
"release": "yarn lint && yarn test && standard-version", | ||
"test": "yarn test:fixture && yarn test:e2e", | ||
"test:fixture": "jest test/fixture", | ||
"test:e2e": "jest test/e2e" | ||
}, | ||
@@ -22,11 +29,25 @@ "publishConfig": { | ||
"devDependencies": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/plugin-syntax-dynamic-import": "^7.2.0", | ||
"@babel/preset-env": "^7.2.3", | ||
"@nuxtjs/eslint-config": "^0.0.1", | ||
"babel-core": "7.0.0-bridge.0", | ||
"babel-eslint": "^10.0.1", | ||
"eslint": "^5.10.0", | ||
"babel-jest": "^23.6.0", | ||
"eslint": "^5.12.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-html": "^5.0.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-node": "^8.0.0", | ||
"eslint-plugin-jest": "^22.1.2", | ||
"eslint-plugin-node": "^8.0.1", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0" | ||
"eslint-plugin-standard": "^4.0.0", | ||
"eslint-plugin-vue": "^5.1.0", | ||
"get-port": "^4.1.0", | ||
"jest": "^23.6.0", | ||
"jsdom": "^13.1.0", | ||
"nuxt": "^2.3.4", | ||
"puppeteer": "^1.11.0", | ||
"standard-version": "^4.4.0" | ||
} | ||
} |
118
README.md
@@ -1,10 +0,9 @@ | ||
# Matomo (previously Piwik) for Nuxt.js | ||
# Matomo integration for Nuxt.js | ||
<a href="https://travis-ci.org/pimlie/nuxt-matomo"><img src="https://api.travis-ci.org/pimlie/nuxt-matomo.svg" alt="Build Status"></a> | ||
[](https://www.npmjs.com/package/nuxt-matomo) | ||
[](https://www.npmjs.com/package/nuxt-matomo) | ||
> Add Matomo to your nuxt.js application. | ||
This plugins automatically sends first page and route change events to matomo | ||
Add Matomo tracking to your nuxt.js application. This plugin automatically sends first page and route change events to matomo | ||
**Note:** matomo is not enabled in `dev` mode. | ||
You can set environment variable `NODE_ENV` to `production` for testing in dev mode. | ||
> nuxt-matomo is not enabled in `dev` mode unless you set the debug option | ||
@@ -20,31 +19,14 @@ ## Setup | ||
## Options | ||
## Usage | ||
### `siteId` | ||
- Required | ||
### Setting configuration at runtime | ||
### `matomoUrl` | ||
You can add additional tracking info by adding a `route.meta.matomo` object in a middleware and by adding a matomo object or function to your page component. | ||
Url to matomo installation | ||
> The VueRouter afterEach guard which this plugin uses is called before your page component is created | ||
### `trackerUrl` | ||
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/fixture/pages/injected.vue) and [manuallytracked](./test/fixture/pages/manuallytracked.vue) pages in the test fixture for an example | ||
Url to piwik.php, default is `matomoUrl + 'piwik.php'` | ||
### `scriptUrl` | ||
Url to piwik.js, default is `matomoUrl + 'piwik.js'` | ||
### `cookies` | ||
If false, Matomo will be configured to not create a tracking cookie | ||
Default: `(unset)` | ||
### Setting configuration at runtime | ||
You can push any additional tracking info to `_paq` at runtime by adding a matomo | ||
object `route.meta.matomo` in the middleware or to the selected pages. An object | ||
is used so we can override middleware variables for selected pages | ||
Middleware example: | ||
```javascript | ||
##### Middleware example | ||
```js | ||
export default function ({ route, store }) { | ||
@@ -60,4 +42,4 @@ route.meta.matomo = { | ||
### Setting configuration at runtime for selected pages | ||
``` | ||
##### Page component example | ||
```js | ||
<template> | ||
@@ -69,6 +51,11 @@ <div> | ||
</template> | ||
<script> | ||
export default { | ||
// the matomo function is binded to the tracker | ||
matomo (from, to, store) { | ||
this.setCustomVariable(1, 'VisitorType', 'Special Member') | ||
}, | ||
// or let the function return an object | ||
matomo (from, to, store) { | ||
return { | ||
@@ -78,9 +65,70 @@ someVar: ['setCustomVariable', 1, 'VisitorType', 'Special Member'] | ||
}, | ||
// or simply set an object | ||
matomo: { | ||
someVar: ['setCustomVariable', 1, 'VisitorType', 'Special Member'] | ||
}, | ||
[...] | ||
} | ||
</script> | ||
``` | ||
``` | ||
### Deprecation warning | ||
## Consent | ||
For the moment you can still use both `matomo` as `piwik` names for your middleware. The piwik name will be removed in a future version. | ||
The plugin extends the matomo tracker with a `setConsent(<consentGiven>)` convenience method. | ||
When `setConsent()` is called, the plugin will automatically call rememberConsentGiven when the module option consentExpires has been set. To forget consent you can pass false to this method. | ||
See the [default layout](./test/fixture/layouts/default.vue) in the test fixture for how to use this method in combination with a Vuex store. | ||
## Options | ||
#### `siteId` (required) | ||
The matomo siteId | ||
#### `matomoUrl` | ||
- Default: ` ` | ||
Url to matomo installation | ||
#### `trackerUrl` | ||
- Default: `matomoUrl + 'piwik.php'` | ||
Url to piwik.php | ||
#### `scriptUrl` | ||
- Default: `matomoUrl + 'piwik.js'` | ||
Url to piwik.js | ||
#### `cookies` | ||
- Default: `true` | ||
If false, Matomo will not create a tracking cookie | ||
#### `consentRequired` | ||
- Default: `false` | ||
If true, Matomo will not start tracking until the user has given consent | ||
#### `consentExpires` | ||
- Default: `0` | ||
If greater than 0 and when the `tracker.setConsent` method is called then we call `rememberConsentGiven(<consentExpires>)` instead of `setConsentGiven`. See below for more information | ||
#### `doNotTrack` | ||
- Default: `false` | ||
If true, dont track users who have set Mozilla's (proposed) Do Not Track setting | ||
#### `debug` | ||
- Default: `false` | ||
If true, the plugin will log debug information to the console. | ||
> The plugin also logs debug information when Nuxt's debug option is set | ||
#### `verbose` | ||
- Default: `false` | ||
If true, the plugin will log every tracker function call to the console |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12517
83.8%7
40%163
123.29%0
-100%131
57.83%22
175%3
50%1
Infinity%