gtm-support / vue-gtm

Simple implementation of Google Tag Manager for Vue
https://www.npmjs.com/package/@gtm-support/vue-gtm
MIT License
205 stars 26 forks source link

The GTM is sending the previous document title #447

Closed Glideh closed 1 month ago

Glideh commented 1 month ago

Info

Tool Version
Plugin v3.0.1
Vue v3.3.11
Node v20.9.0
OS Dockerized Alpine

Input

Before this JS, the document title is Previous product

const page_title = 'Current product'
document.title = page_title
gtm.trackView(route.name.toString() + route.path, { page_title })

Output or Error

I'm getting the page view with the Previous product page title

Expected Output

Get the Current product page title

Additional Context

Here I'm getting some product data asynchronously from an API then appending it on the document title before firing the trackView. Also, I'm actually using the vueRouter option just excluding this route to fire it manually.

app.use(createGtm({
    id: gtmId,
    vueRouter: router,
    ignoredViews: ['product'],
}))
Shinigami92 commented 1 month ago

Could you try enabling the trackOnNextTick option?

Glideh commented 1 month ago

Yes I tried that too, didn't seem to have any effect

Shinigami92 commented 1 month ago

You have several possibilities now:

Glideh commented 1 month ago

Thanks for your suggestions I'll try that

Glideh commented 1 month ago

Turned out we misread the events in the console... It's actually working fine. Thanks again for your help, sorry for the false alarm