---
title: "Script Event Page · Nuxt Scripts"
description: "Learn how to send page events to your analytics provider."
canonical_url: "https://scripts.nuxt.com/docs/guides/page-events"
meta:
  "og:description": "Learn how to send page events to your analytics provider."
  "og:image": "https://scripts.nuxt.com/_og/s/o_b298a5fb7304611e.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Script Event Page · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_b298a5fb7304611e.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Guides**

# **Script Event Page**

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

## Background

Analytics scripts often send an event after each route change. Nuxt's [`**page:finish**`** hook**](https://nuxt.com/docs/4.x/api/advanced/hooks#app-hooks-runtime) runs after the page's Suspense tree resolves, but a queued head update may still be pending.

[`**useScriptEventPage()**`](https://scripts.nuxt.com/docs/api/use-script-event-page) listens for `**page:finish**`, then waits for Unhead to render the DOM (or for a 100 ms fallback) before reading `**document.title**` and the route's full path. Its callback runs only in the browser.

If you register the composable before Nuxt emits the initial `**page:finish**`, the first callback covers the initial render. Registering it later tracks only subsequent navigations.

## Usage

Pass a callback and send the resolved values to your analytics provider:

```ts
const { proxy } = useScriptGoogleAnalytics()

useScriptEventPage(({ title, path }) => {
  // Triggered after the initial render and each route change
  proxy.gtag('event', 'page_view', {
    page_title: title,
    page_location: window.location.href,
    page_path: path,
  })
})
```

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/1.guides/3.page-events.md)

[Markdown For LLMs](https://scripts.nuxt.com/docs/guides/page-events.md)

[**Cookie Consent** Gate scripts behind user consent and drive vendor-native consent APIs through a typed per-script \`consent\` object.](https://scripts.nuxt.com/docs/guides/consent) [**Global Scripts** Configure global scripts with triggers, warmup, typed access, and runtime URL overrides.](https://scripts.nuxt.com/docs/guides/global)

**On this page **

- [Background](#background)
- [Usage](#usage)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","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.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/docs/guides/page-events#webpage","@type":"WebPage","description":"Learn how to send page events to your analytics provider.","name":"Script Event Page","url":"https://scripts.nuxt.com/docs/guides/page-events","breadcrumb":{"@id":"https://scripts.nuxt.com/docs/guides/page-events#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/docs/guides/page-events"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/docs/guides/page-events#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Documentation","item":"https://scripts.nuxt.com/docs","position":2},{"@type":"ListItem","name":"Guides","item":"https://scripts.nuxt.com/docs/guides","position":3},{"@type":"ListItem","name":"Script Event Page","item":"https://scripts.nuxt.com/docs/guides/page-events","position":4}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
