Skip to content

Commit 45e0014

Browse files
committed
refactor: google analytics
1 parent 0853f98 commit 45e0014

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

theme.config.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import { DocsThemeConfig, useConfig } from "nextra-theme-docs";
33
import { useRouter } from "next/router";
44
import { GoogleAnalytics } from '@next/third-parties/google'
5+
import Script from "next/script";
56

67
const config: DocsThemeConfig = {
78
head: () => {
@@ -10,9 +11,23 @@ const config: DocsThemeConfig = {
1011
const defaultDescription = "Documentation for VZN Scripts assets";
1112
const url = `https://docs.vzn-scripts.com/${asPath}`;
1213

14+
const googleId = "G-XV58K6R2PX"
15+
1316
return (
1417
<>
15-
<GoogleAnalytics gaId="G-XV58K6R2PX" />
18+
<Script
19+
strategy='lazyOnload'
20+
src={`https://www.googletagmanager.com/gtag/js?id=${googleId}`}
21+
/>
22+
23+
<Script id='' strategy='lazyOnload'>
24+
{`
25+
window.dataLayer = window.dataLayer || [];
26+
function gtag(){dataLayer.push(arguments);}
27+
gtag('js', new Date());
28+
gtag('config', '${googleId}');
29+
`}
30+
</Script>
1631
<link rel="icon" type="image/png" href="/logo.png" />
1732

1833
<meta httpEquiv="Content-Language" content="en" />

0 commit comments

Comments
 (0)