add google analytics
This commit is contained in:
parent
cd22f97992
commit
2fd9645978
@ -1,7 +1,7 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import { Geist, Geist_Mono } from "next/font/google";
|
import { Geist, Geist_Mono } from "next/font/google";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
import YandexMetrika from '@/components/metrika';
|
import { YandexMetrika, GoogleAnalytics } from '@/components/metrika';
|
||||||
|
|
||||||
const geistSans = Geist({
|
const geistSans = Geist({
|
||||||
variable: "--font-geist-sans",
|
variable: "--font-geist-sans",
|
||||||
@ -39,6 +39,7 @@ export default function RootLayout({
|
|||||||
{children}
|
{children}
|
||||||
|
|
||||||
<YandexMetrika id="100593564" />
|
<YandexMetrika id="100593564" />
|
||||||
|
<GoogleAnalytics id="G-9B4KQ08EKR" />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable @next/next/no-img-element */
|
/* eslint-disable @next/next/no-img-element */
|
||||||
import Script from 'next/script'
|
import Script from 'next/script'
|
||||||
|
|
||||||
const YandexMetrika = ({ id }: { id: string }) => (
|
export const YandexMetrika = ({ id }: { id: string }) => (
|
||||||
<>
|
<>
|
||||||
<Script
|
<Script
|
||||||
id='yandex-metrika'
|
id='yandex-metrika'
|
||||||
@ -38,4 +38,21 @@ const YandexMetrika = ({ id }: { id: string }) => (
|
|||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
export default YandexMetrika
|
export const GoogleAnalytics = ({ id }: { id: string }) => (
|
||||||
|
<>
|
||||||
|
<Script async src={`https://www.googletagmanager.com/gtag/js?id=${id}`} />
|
||||||
|
<Script
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: `
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', '${id}');
|
||||||
|
`,
|
||||||
|
}}
|
||||||
|
id='gtm'
|
||||||
|
strategy='afterInteractive'
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user