Skip to content

Instantly share code, notes, and snippets.

@popeating
Created July 13, 2023 21:21
Show Gist options
  • Save popeating/b7c61a9074d479992f2aef5b7659c126 to your computer and use it in GitHub Desktop.
Save popeating/b7c61a9074d479992f2aef5b7659c126 to your computer and use it in GitHub Desktop.
layout.js
import './globals.css';
import { Inter } from 'next/font/google';
import Script from 'next/script';
const inter = Inter({ subsets: ['latin'] });
export const metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
};
export default function RootLayout({ children }) {
return (
<html lang="en">
<Script
id="gtag"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
(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-XXXXXX');`,
}}
/>
<body className={inter.className}>{children}</body>
</html>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment