AmazingDreams / vue-matomo

Vue plugin for Matomo Analytics
MIT License
282 stars 61 forks source link

Tracking of dynamic page titles #13

Closed siulca closed 6 years ago

siulca commented 6 years ago

I'm using vue-matomo with a package that enables changing the page title upon route change. However the tracking of page titles isn't working consistently. Something motomo tracks the title, sometimes it tracks the URL as the title. Sometimes it tracks the title as ''Page Name Not Defined"

image

AmazingDreams commented 6 years ago

Yeah, the underlying problem is that vue-router calls the afterEach listeners before the page contents and even the window.location changes. https://github.com/AmazingDreams/vue-matomo/blob/master/src/index.js#L40

Perhaps a solution would be to set a timeout to like 50ms or something, and then signal the matomo tracker to track a page view

siulca commented 6 years ago

Would that explain the inconsistency with the page URLs also? Sometimes they are tracked with a forward slash, sometimes aren't.

image

siulca commented 6 years ago

Would you be able to implement that delay in vue-motomo itself? It'd be all self-contained that way and maybe provide a delay variable that can be setup via the setup options object.

AmazingDreams commented 6 years ago

Yeah, I couldn't use the window.location so I had to construct my own page url from the data given by the router. It depends on your router definition. Maybe you have extra forward slashes there.

A timeout is perhaps better. Just let matomo figure it out, they've put a lot of work into page tracking already so.

AmazingDreams commented 6 years ago

Unfortunately matomo simply isn't built for out of the box tracking of single page apps. I've tried some stuff but I'm back to using my own (slightly improved) url determination code.

I'm using the route's name, do you think this could be causing issues for you?

siulca commented 6 years ago

Yeah, because route names aren't compulsory.

Unfortunately matomo simply isn't built for out of the box tracking of single page apps.

What makes you believe this?

AmazingDreams commented 6 years ago

What makes you believe this?

It simply won't update the page url by itself.

See if v0.5.1 works for you.

siulca commented 6 years ago

Will try later. What are you using bootstrap for?!

AmazingDreams commented 6 years ago

I'm not using bootstrap CSS framework. bootstrap.js is the script that pulls in the matomo JS

siulca commented 6 years ago

You mean you're using bootstrap to load matomo? Can't it be done with Axios?

AmazingDreams commented 6 years ago

No it's just the name I used for the script, not a library

AmazingDreams commented 6 years ago

I'll close this one for now feel free to reopen.