Google Tag Manager shows previous page title after navigation with Swup #987
Unanswered
NereaFontecha
asked this question in
Help
Replies: 2 comments 3 replies
-
|
One idea is you could add a small artificial delay using Alternatively, you could use the title of the new document directly. The hook should receive a |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Hi @daun , I have noticed that the setTimeout function is not working as expected. Additionally, the function responsible for retrieving the page title is executed before the title has been updated.Any further ideas? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe your problem 🧐
We're using Swup for smooth, SPA-like navigation, along with Google Tag Manager (GTM). We've noticed that when we navigate to a new page, the document.title being pushed to GTM corresponds to the previous page, not the current one.
This happens even though we're using Swup’s page:view event and pushing data to window.dataLayer.
In some projects with little content, the title updates correctly before the dataLayer push. here
In this specific project, it seems like document.title hasn't updated yet when the page:view hook here.
Example of the behavior:
You're on page-A → Correct title in GTM: ✅
Navigate to page-B → GTM still shows the title of page-A ❌
Navigate to page-C → GTM now shows the title of page-B ❌
Current setup:
What is your question? 🙋♀️
Is there a recommended Swup hook we should use to ensure that document.title has been fully updated before pushing data to dataLayer?
Should we maybe listen for a different event (like contentReplaced, animationOutDone, etc.) before triggering the push?
URL to minimal reproduction 🔗
http://sei.com/
Checked all these? 📚
Beta Was this translation helpful? Give feedback.
All reactions