diff --git a/packages/web/src/astro/index.astro b/packages/web/src/astro/index.astro index 52bac82..fde23a9 100644 --- a/packages/web/src/astro/index.astro +++ b/packages/web/src/astro/index.astro @@ -44,7 +44,11 @@ const paramsStr = JSON.stringify(Astro.params); beforeSend: window.webAnalyticsBeforeSend, }); const path = this.dataset.pathname; - pageview({ route: computeRoute(path ?? '', params), path }); + pageview({ + route: computeRoute(path ?? '', params), + path, + title: document.title, + }); } catch (err) { throw new Error(`Failed to parse WebAnalytics properties: ${err}`); } diff --git a/packages/web/src/generic.ts b/packages/web/src/generic.ts index 6c56a2b..b1b9f09 100644 --- a/packages/web/src/generic.ts +++ b/packages/web/src/generic.ts @@ -142,11 +142,13 @@ function track( function pageview({ route, path, + title, }: { route?: string | null; path?: string; + title?: string; }): void { - window.va?.('pageview', { route, path }); + window.va?.('pageview', { route, path, title }); } export { inject, track, pageview, computeRoute }; diff --git a/packages/web/src/react/index.tsx b/packages/web/src/react/index.tsx index eeb5e80..b1a9bbc 100644 --- a/packages/web/src/react/index.tsx +++ b/packages/web/src/react/index.tsx @@ -33,6 +33,7 @@ function Analytics( route?: string | null; path?: string | null; basePath?: string; + title?: string; } ): null { useEffect(() => { @@ -55,7 +56,11 @@ function Analytics( useEffect(() => { // explicitely track page view, since we disabled auto tracking if (props.route && props.path) { - pageview({ route: props.route, path: props.path }); + pageview({ + route: props.route, + path: props.path, + title: document.title, + }); } }, [props.route, props.path]); diff --git a/packages/web/src/remix/index.tsx b/packages/web/src/remix/index.tsx index 17e09cc..fec9957 100644 --- a/packages/web/src/remix/index.tsx +++ b/packages/web/src/remix/index.tsx @@ -10,6 +10,7 @@ export function Analytics(props: Omit): JSX.Element { {...props} basePath={getBasePath()} framework="remix" + title={document.title} /> ); } diff --git a/packages/web/src/sveltekit/index.ts b/packages/web/src/sveltekit/index.ts index 6c1dba4..acc3032 100644 --- a/packages/web/src/sveltekit/index.ts +++ b/packages/web/src/sveltekit/index.ts @@ -17,7 +17,11 @@ function injectAnalytics(props: Omit = {}): void { page.subscribe(({ route, url }) => { // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route could be undefined in layout.js file if (route?.id) { - pageview({ route: route.id, path: url.pathname }); + pageview({ + route: route.id, + path: url.pathname, + title: document.title, + }); } }); } diff --git a/packages/web/src/vue/create-component.ts b/packages/web/src/vue/create-component.ts index df88963..140ce8b 100644 --- a/packages/web/src/vue/create-component.ts +++ b/packages/web/src/vue/create-component.ts @@ -26,6 +26,7 @@ export function createComponent( pageview({ route: computeRoute(route.path, route.params), path: route.path, + title: document.title, }); }; changeRoute();