Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 40d8af1

Browse files
feat(page): adds possibility to ignore also route path value
closes #152
1 parent c81a5eb commit 40d8af1

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

docs/page-tracking.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Vue.use(VueAnalytics, {
2121
})
2222
```
2323

24-
### Manual page tracking
24+
### Manual page tracking
2525

2626
The standard way is just passing the current page path
2727

@@ -101,12 +101,13 @@ Vue.use(VueAnalytics, {
101101

102102
### Ignore routes on page auto tracking
103103

104-
To disable auto tracking for specific routes, you need to pass an array of names of routes to the plugin options
104+
To disable auto tracking for specific routes, you need to pass an array of strings to the plugin options.
105+
The string needs to be the route `name` or the route `path`.
105106

106107
```js
107108
Vue.use(VueAnalytics, {
108109
router,
109-
ignoreRoutes: ['home', 'contacts']
110+
ignoreRoutes: ['home', '/contacts']
110111
})
111112
```
112113

src/helpers.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ export function getQueryString (queryMap) {
9292
return queryString !== '' ? `?${queryString}` : ''
9393
}
9494

95-
export function isRouteIgnored (name) {
96-
return config.ignoreRoutes.indexOf(name) !== -1
95+
export function isRouteIgnored ({ name, path }) {
96+
return [name, path]
97+
.filter(Boolean)
98+
.find(value => config.ignoreRoutes.indexOf(value) !== -1)
9799
}
98100

99101
export function isRoute (data) {

src/lib/page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function page (...args) {
3535
}
3636

3737
export function trackRoute (route) {
38-
if (isRouteIgnored(route.name)) {
38+
if (isRouteIgnored(route)) {
3939
return
4040
}
4141

0 commit comments

Comments
 (0)