19

Github feat: 支持 GA · juzhiyuan/blog@c0a5ded · GitHub

 3 years ago
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.
neoserver,ios ssh client

支持 GA · juzhiyuan/blog@c0a5ded · GitHubPermalink

Browse files

feat: 支持 GA

juzhiyuan

committed 10 hours ago

1 parent a62060d commit c0a5dedaa3214aa40ee0206e3dd6a77bfad787ae
Showing with 32 additions and 0 deletions.

@@ -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>

);

}

}


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK