File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,15 @@ Vue.use(VueMatomo, {
109109 // ]
110110 preInitActions: [],
111111
112+ // A function to determine whether to track a router page change. If not a function
113+ // all interactions will be tracked. Receives both the new route and the previous route
114+ // and returns either true or false. True if the interaction should be tracked, false
115+ // if the interaction should be ignored
116+ // Default: undefined
117+ // Example: (to, from) => {
118+ // return !(from && to.path === from.path)
119+ // }
120+ trackInteraction: undefined ,
112121 // A function to determine whether to track an interaction as a site search
113122 // instead of as a page view. If not a function, all interactions will be
114123 // tracked as page views. Receives the new route as an argument, and
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const defaultOptions = {
1010 requireConsent : false ,
1111 trackInitialView : true ,
1212 trackSiteSearch : false ,
13+ trackInteraction : undefined ,
1314 trackerFileName : 'matomo' ,
1415 trackerUrl : undefined ,
1516 trackerScriptUrl : undefined ,
@@ -23,6 +24,10 @@ const defaultOptions = {
2324export const matomoKey = 'Matomo'
2425
2526function trackUserInteraction ( options , to , from ) {
27+ if ( typeof options . trackInteraction === 'function' && ! options . trackInteraction ( to , from ) ) {
28+ return
29+ }
30+
2631 if ( typeof options . trackSiteSearch === 'function' ) {
2732 const siteSearch = options . trackSiteSearch ( to )
2833 if ( siteSearch ) {
You can’t perform that action at this time.
0 commit comments