mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-04 03:42:34 +02:00
fix(gtag): send the newly rendered page's title instead of the old one's (#7424)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com> Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
7ab97d4726
commit
49ecd8f472
2 changed files with 27 additions and 14 deletions
|
@ -13,10 +13,16 @@ function logPage(
|
|||
location: Location,
|
||||
previousLocation: Location | null,
|
||||
): void {
|
||||
console.log(`${event}
|
||||
Previous location: ${previousLocation?.pathname}
|
||||
Current location: ${location.pathname}
|
||||
Current heading: ${document.getElementsByTagName('h1')[0]?.innerText}`);
|
||||
console.log(event, location.pathname, {
|
||||
location,
|
||||
prevLocation: previousLocation,
|
||||
heading: document.getElementsByTagName('h1')[0]?.innerText,
|
||||
title: document.title,
|
||||
description: (
|
||||
document.querySelector('meta[name="description"]') as HTMLMetaElement
|
||||
)?.content,
|
||||
htmlClassName: document.getElementsByTagName('html')[0]?.className,
|
||||
});
|
||||
}
|
||||
|
||||
export function onRouteUpdate({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue