Skip to content

Commit

Permalink
Merge pull request #71 from newfish-cmyk/add-google
Browse files Browse the repository at this point in the history
add google tag manager
  • Loading branch information
yangchuansheng authored Oct 31, 2024
2 parents 8de7138 + 9260533 commit b5b23d0
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions projects/fastgpt/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '@/styles/plyr.css';
import { Analytics } from '@vercel/analytics/react';
import { Viewport } from 'next';
import { Inter as FontSans } from 'next/font/google';
import Script from 'next/script';

const fontSans = FontSans({
subsets: ['latin'],
Expand Down Expand Up @@ -44,12 +45,36 @@ export default async function RootLayout({
children: React.ReactNode;
params: { lang: string[] | undefined };
}) {
const isChineseDomain = process.env.NEXT_PUBLIC_USER_URL?.includes('.cn') || process.env.NEXT_PUBLIC_USER_URL?.includes('.run');

return (
<html lang={(lang && lang[0]) || defaultLocale} suppressHydrationWarning>
<head />
<body className={cn('min-h-screen font-sans antialiased', fontSans.variable)}
// style={{background: 'var(--background-gradient)'}}
>
<head>
{!isChineseDomain && (
<Script
id="gtm-script"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W9HPZZ22');`
}}
/>
)}
</head>
<body className={cn('min-h-screen font-sans antialiased', fontSans.variable)}>
{!isChineseDomain && (
<noscript>
<iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-W9HPZZ22"
height="0"
width="0"
style={{display: 'none', visibility: 'hidden'}}
></iframe>
</noscript>
)}
<ThemeProvider attribute="class" defaultTheme={siteConfig.nextThemeColor} enableSystem>
{children}
{/* <Footer /> */}
Expand Down

0 comments on commit b5b23d0

Please sign in to comment.