Skip to content

[Vue] Can't synchronise head title with analytics tools #615

Closed

Description

@Vasile-Peste

Environment

"@unhead/vue": "^2.0.19"
"vite": "^7.2.7"
"vue": "^3.5.25"

Reproduction

Hi! First of all thanks for creating this great library

Now, I'm having a hard time synchronising the update of the page title with the initialisation of analytics solutions such as Amplitude.
The issue is that as soon as an analytics monitoring is initialised, it will capture the default page title of index.html.

Example App.vue:

<template>
    <RouterView/> <!-- It loads a View which uses useHead() to set the title -->
</template>

<script setup>
// [ . . . ]

useHead({
    link: [
        {
            rel: "canonical",
            href: canonicalUri,
        },
    ],
    meta: [
        // [ . . . ]
    ],
});

const amplitudeClient = inject("amplitudeClient");

onMounted(() => {
    // <amplitude>
    // Used to wait for the route to be rendered before initialising Amplitude
    (async () => {
        await nextTick();
        await amplitudeClient?.init();
    })();
    // </amplitude>
});

fetch();
</script>

<RouterView> loads the actual user view which will initialise again useHead() with the page title

So if the index.html has "App Name - Loading..." as title, Amplitude and other Analytics tools will capture it and send as event. Is there smooth way to expose the useHead() DOM updates so we can synchronise it with analytics?

Another solution that I tried consisted of using router.afterEach() then awaiting a next tick and initialising the analytics, it didn't work either as the window.document.title still wasn't updated at that point.

Describe the bug

Please check the reproduction section.

Additional context

No response

Logs

Activity

  1. added
    bug
    on Dec 16, 2025
  2. added a commit that references this issue on Mar 10, 2026
    b7caf9e
  3. added a commit that references this issue on Apr 4, 2026
    f7181f2
  4. added a commit that references this issue on Apr 5, 2026
    55166ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions