Github feat: 支持 GA · juzhiyuan/blog@c0a5ded · GitHub
source link: https://github.com/juzhiyuan/blog/commit/c0a5dedaa3214aa40ee0206e3dd6a77bfad787ae
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
支持 GA · juzhiyuan/blog@c0a5ded · GitHubPermalink
@@ -0,0 +1,32 @@
import Document, { Html, Head, Main, NextScript } from "next/document";
const GA_TRACKING_ID = "G-JR4TTDY4D1";
export default class MyDocument extends Document {
render() {
return (
<Html>
<Head>
<script
async
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
/>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_TRACKING_ID}');
`,
}}
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK