AmazingDreams / vue-matomo

Vue plugin for Matomo Analytics
MIT License
272 stars 60 forks source link

Set custom url doesn't seem to work #97

Closed AdamSGit closed 2 years ago

AdamSGit commented 2 years ago

Hello,

I have urls with route params following this pattern :

I want to group them in matomo report as follow : https://example.com/url/to/the/page

So I tried to use the setCustomUrl options in the router beforeeach hook, as follow : window._paq && window._paq.push(['setCustomUrl', filteredUrl])

It doesn't seem to work, as I see all the differents urls in matomo report. Something weird is that in the network tab of debugging tools, I see two requests. Both seem to be pageview. The first has the filtered URL, and the other the full one. I'm not sure if the two pageviews are taken into account but I can't be sure.

Any clue on this ? Thanks

AmazingDreams commented 2 years ago

Hi,

Due to Vue being an SPA this plugin uses the custom url to set the page url. Otherwise it would always be the url used on first page load.

Though I realise now this isn't properly documented, you can use a route meta.title to set a page name, similar to meta.analyticsIgnore

https://github.com/AmazingDreams/vue-matomo#ignoring-routes

Let me know if this helps or not

AdamSGit commented 2 years ago

Well, I think it could work to ignore route and track it with custom url in beforeeach hook. So this issue can be closed. I will let you know if it doesn't work for some reasons.

Thanks