feat: 添加 Google Analytics 跟踪脚本
This commit is contained in:
@@ -129,6 +129,22 @@ export default async function RootLayout({
|
|||||||
return (
|
return (
|
||||||
<html lang={locale} className="dark" suppressHydrationWarning>
|
<html lang={locale} className="dark" suppressHydrationWarning>
|
||||||
<head>
|
<head>
|
||||||
|
{/* Google tag (gtag.js) */}
|
||||||
|
<script
|
||||||
|
async
|
||||||
|
src="https://www.googletagmanager.com/gtag/js?id=G-GH6V4XBY2Z"
|
||||||
|
/>
|
||||||
|
<script
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: `
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
|
||||||
|
gtag('config', 'G-GH6V4XBY2Z');
|
||||||
|
`.trim(),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<WebSiteStructuredData />
|
<WebSiteStructuredData />
|
||||||
<OrganizationStructuredData />
|
<OrganizationStructuredData />
|
||||||
{/* Inline script to set locale before React hydrates, preventing flash */}
|
{/* Inline script to set locale before React hydrates, preventing flash */}
|
||||||
|
|||||||
Reference in New Issue
Block a user