vue-matomo
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -18,2 +18,7 @@ // The Vue build version to load with the `import` command | ||
// Enables link tracking on regular links. Note that this won't | ||
// work for routing links (ie. internal Vue router links) | ||
// Default: true | ||
enableLinkTracking: true, | ||
// Require consent before sending tracking information to matomo | ||
@@ -29,3 +34,7 @@ // Default: false | ||
// Default: 'piwik' | ||
trackerFileName: 'piwik' | ||
trackerFileName: 'piwik', | ||
// Whether or not to log debug information | ||
// Default: false | ||
debug: true | ||
}) | ||
@@ -32,0 +41,0 @@ |
@@ -5,2 +5,3 @@ import Vue from 'vue' | ||
import Page1 from '@/components/Page1' | ||
import Page2 from '@/components/Page2' | ||
@@ -12,4 +13,12 @@ Vue.use(Router) | ||
{ path: '/', name: 'HelloWorld', component: HelloWorld }, | ||
{ path: '/page-1', name: 'Page1', component: Page1 } | ||
{ path: '/page-1', name: 'Page1', component: Page1 }, | ||
{ | ||
path: '/page-2', | ||
name: 'Page2', | ||
component: Page2, | ||
meta: { | ||
analyticsIgnore: true | ||
} | ||
} | ||
] | ||
}) |
@@ -1,1 +0,1 @@ | ||
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t=r();for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}("undefined"!=typeof self?self:this,function(){return function(e){function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}var t={};return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=0)}([function(e,r,t){"use strict";function o(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},i,r),o=t.host,c=t.siteId,u=t.trackerFileName;e.prototype.$piwik=a,e.prototype.$matomo=a,a.setTrackerUrl(o+"/"+u+".php"),a.setSiteId(c),t.requireConsent&&a.requireConsent(),t.trackInitialView&&a.trackPageView(),t.enableLinkTracking&&a.enableLinkTracking(),t.router&&t.router.afterEach(function(e,r){var o=window.location,n=o.protocol;":"!==n.slice(-1)&&(n+=":"),console.log(t.router);var i="hash"===t.router.mode?"/#":"",c=n+"//"+o.host+i+e.path;a.setCustomUrl(c),a.trackPageView()}),n(t)}Object.defineProperty(r,"__esModule",{value:!0});var n=function(e){var r=e.host,t=e.trackerFileName,o=r+"/"+t+".js",n=new Promise(function(e,r){var t=document.createElement("script");t.async=!0,t.defer=!0,t.src=o,(document.head||document.getElementsByTagName("head")[0]).appendChild(t),t.onload=e,t.onerror=r});return n.catch(function(e){var r="[vue-matomo] An error occurred trying to load "+e.target.src+". If the file exists you may have an ad- or trackingblocker enabled.";console.error(r)}),n},a=new Proxy({},{get:function(e,r,t){return window._paq=window._paq||[],function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];var n=[r].concat(t);console.debug(n),window._paq.push(n)}}});r.default=o;var i={enableLinkTracking:!0,requireConsent:!1,trackInitialView:!0,trackerFileName:"piwik"}}])}); | ||
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t=r();for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}("undefined"!=typeof self?self:this,function(){return function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var t={};return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=0)}([function(e,r,t){"use strict";function n(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},i,r),n=t.host,c=t.siteId,u=t.trackerFileName;e.prototype.$piwik=a,e.prototype.$matomo=a,a.setTrackerUrl(n+"/"+u+".php"),a.setSiteId(c),t.requireConsent&&a.requireConsent(),t.trackInitialView&&a.trackPageView(),t.enableLinkTracking&&a.enableLinkTracking(),t.router&&t.router.afterEach(function(e,r){var n=window.location,o=n.protocol;":"!==o.slice(-1)&&(o+=":");var i="hash"===t.router.mode?"/#":"",c=o+"//"+n.host+i+e.path;if(e.meta.analyticsIgnore)return void(t.debug&&console.debug("[vue-matomo] Ignoring "+c));t.debug&&console.debug("[vue-matomo] Tracking "+c),a.setCustomUrl(c),a.trackPageView()}),o(t)}Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){var r=e.host,t=e.trackerFileName,n=r+"/"+t+".js",o=new Promise(function(e,r){var t=document.createElement("script");t.async=!0,t.defer=!0,t.src=n,(document.head||document.getElementsByTagName("head")[0]).appendChild(t),t.onload=e,t.onerror=r});return o.catch(function(e){var r="[vue-matomo] An error occurred trying to load "+e.target.src+". If the file exists you may have an ad- or trackingblocker enabled.";console.error(r)}),o},a=new Proxy({},{get:function(e,r,t){return window._paq=window._paq||[],function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var o=[r].concat(t);window._paq.push(o)}}});r.default=n;var i={debug:!1,enableLinkTracking:!0,requireConsent:!1,trackInitialView:!0,trackerFileName:"piwik"}}])}); |
{ | ||
"name": "vue-matomo", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "Link your Piwik/Matomo installation", | ||
@@ -9,3 +9,3 @@ "author": "Dennis Ruhe <dennis@amazingsystems.nl>", | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org" | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
@@ -12,0 +12,0 @@ "scripts": { |
@@ -46,3 +46,7 @@ # VueMatomo | ||
// Default: 'piwik' | ||
trackerFileName: 'piwik' | ||
trackerFileName: 'piwik', | ||
// Whether or not to log debug information | ||
// Default: false | ||
debug: false | ||
}); | ||
@@ -62,2 +66,18 @@ | ||
### Ignoring routes | ||
It is possible to ignore routes using the route meta: | ||
```js | ||
{ | ||
path: '/page-2', | ||
name: 'Page2', | ||
component: Page2, | ||
meta: { | ||
analyticsIgnore: true | ||
} | ||
} | ||
``` | ||
### Browser | ||
@@ -64,0 +84,0 @@ |
@@ -5,2 +5,3 @@ import bootstrap from './bootstrap' | ||
const defaultOptions = { | ||
debug: false, | ||
enableLinkTracking: true, | ||
@@ -40,4 +41,5 @@ requireConsent: false, | ||
options.router.afterEach((to, from) => { | ||
// Unfortunately the window location is not yet updated here | ||
// We need to make our own ulr using the data provided by the router | ||
// We need to make our own url using the data provided by the router | ||
const loc = window.location | ||
@@ -51,7 +53,12 @@ | ||
console.log(options.router) | ||
const maybeHash = options.router.mode === 'hash' ? '/#' : '' | ||
const url = protocol + '//' + loc.host + maybeHash + to.path | ||
if (to.meta.analyticsIgnore) { | ||
options.debug && console.debug('[vue-matomo] Ignoring ' + url) | ||
return | ||
} | ||
options.debug && console.debug('[vue-matomo] Tracking ' + url) | ||
Matomo.setCustomUrl(url) | ||
@@ -58,0 +65,0 @@ Matomo.trackPageView() |
@@ -7,3 +7,2 @@ export default new Proxy({}, { | ||
const arr = [name].concat(args) | ||
console.debug(arr) | ||
window._paq.push(arr) | ||
@@ -10,0 +9,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65307
51
1108
103