---
title: "Script Event Page · Nuxt Scripts"
meta:
  description: "Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box."
  "og:description": "Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box."
  "og:title": "Script Event Page · Nuxt Scripts"
---

```

Nuxt Scripts on GitHub

**

**Guides**

# **Script Event Page**

[Copy for LLMs](https://scripts.nuxt.com/docs/v0/guides/page-events.md)

## Background

When using tracking scripts, it's common to send an event when the page changes. Due to Nuxt's head implementation being async, the page title is not always available on route change immediately.

Nuxt Scripts provides the [**~~useScriptEventPage~~**](https://scripts.nuxt.com/docs/api/use-script-event-page) composable to solve this problem.

See the [**~~API~~**](https://scripts.nuxt.com/docs/api/use-script-event-page) docs for full details on the available options.

### Usage

The composable works by providing a function that will be invoked whenever the page changes, providing the newly resolved title and path.

You can use this with any analytics provider where you're seeing the page title not being accurate on route change.

```
const { proxy } = useScriptGoogleAnalytics()

useScriptEventPage(({ title, path }) => {
  // triggered on route change
  proxy.gtag('event', 'page_view', {
    page_title: title,
    page_location: 'https://example.com',
    page_path: path
  })
})
```[~~Edit this page~~](https://github.com/nuxt/scripts/edit/0.x/docs/content/docs/v0/1.guides/3.page-events.md) [~~Markdown For LLMs~~](https://scripts.nuxt.com/docs/v0/guides/page-events.md) [**Consent Management** Learn how to get user consent before loading scripts.](https://scripts.nuxt.com/docs/v0/guides/consent) [**Global Scripts** Load global third-party scripts and optimize them for your Nuxt app.](https://scripts.nuxt.com/docs/v0/guides/global)