Fixing google analytics, adding some changes from prod

This commit is contained in:
Vladislav Khorev 2024-02-25 19:20:22 +00:00
parent 82eb226810
commit 3c4661a9c8
5 changed files with 456 additions and 585 deletions

View File

@ -9,10 +9,11 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@next/third-parties": "^14.1.0",
"axios": "^1.6.5", "axios": "^1.6.5",
"dotenv": "^16.4.1", "dotenv": "^16.4.1",
"leaflet": "^1.9.4", "leaflet": "^1.9.4",
"next": "14.1.0", "next": "^14.1.0",
"next-auth": "^4.24.5", "next-auth": "^4.24.5",
"react": "^18", "react": "^18",
"react-dom": "^18", "react-dom": "^18",

View File

@ -5,18 +5,8 @@ import "./App.scss";
import { Providers } from "./Providers"; import { Providers } from "./Providers";
import Navbar from "@/widgets/Navbar/Navbar"; import Navbar from "@/widgets/Navbar/Navbar";
import Footer from "@/widgets/Footer/Footer"; import Footer from "@/widgets/Footer/Footer";
import { GoogleAnalytics } from '@next/third-parties/google'
const googleAnalyticsHtml = `
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-0BMJ2KN7F8"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-0BMJ2KN7F8');
</script>
`
export default function RootLayout({ export default function RootLayout({
children, children,
@ -25,7 +15,8 @@ export default function RootLayout({
}>) { }>) {
return ( return (
<html lang="en"> <html lang="en">
<head dangerouslySetInnerHTML={{ __html: googleAnalyticsHtml }} /> <head>
</head>
<body> <body>
<Providers> <Providers>
<Navbar /> <Navbar />
@ -33,6 +24,7 @@ export default function RootLayout({
<Footer /> <Footer />
</Providers> </Providers>
</body> </body>
<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS || ""} />
</html> </html>
); );
} }

View File

@ -8,42 +8,9 @@ import facebook from "./icons/facebook.svg";
import instagram from "./icons/instagram.svg"; import instagram from "./icons/instagram.svg";
import app_store_btn from "./icons/app-store-btn.svg"; import app_store_btn from "./icons/app-store-btn.svg";
import play_market_btn from "./icons/play-market-btn.svg"; import play_market_btn from "./icons/play-market-btn.svg";
import NetKgTracker from "@/widgets/NetKgTracker/NetKgTracker";
const Footer = () => { const Footer = () => {
const netKgFooterScript =`
<!-- WWW.NET.KG , code for http://kgroad.org -->
<script language="javascript" type="text/javascript">
java="1.0";
java1=""+"refer="+escape(document.referrer)+"&amp;page="+escape(window.location.href);
document.cookie="astratop=1; path=/";
java1+="&amp;c="+(document.cookie?"yes":"now");
</script>
<script language="javascript1.1" type="text/javascript">
java="1.1";
java1+="&amp;java="+(navigator.javaEnabled()?"yes":"now");
</script>
<script language="javascript1.2" type="text/javascript">
java="1.2";
java1+="&amp;razresh="+screen.width+'x'+screen.height+"&amp;cvet="+
(((navigator.appName.substring(0,3)=="Mic"))?
screen.colorDepth:screen.pixelDepth);
</script>
<script language="javascript1.3" type="text/javascript">java="1.3"</script>
<script language="javascript" type="text/javascript">
java1+="&amp;jscript="+java+"&amp;rand="+Math.random();
document.write("<a href='https://www.net.kg/stat.php?id=7235&amp;fromsite=7235' target='_blank'>"+
"<img src='https://www.net.kg/img.php?id=7235&amp;"+java1+
"' border='0' alt='WWW.NET.KG' width='88' height='31' /></a>");
</script>
<noscript>
<a href='https://www.net.kg/stat.php?id=7235&amp;fromsite=7235' target='_blank'><img
src="https://www.net.kg/img.php?id=7235" border='0' alt='WWW.NET.KG' width='88'
height='31' /></a>
</noscript>
<!-- /WWW.NET.KG -->
`
return ( return (
<footer className="footer"> <footer className="footer">
<Link href="/"> <Link href="/">
@ -60,7 +27,7 @@ const Footer = () => {
</li> </li>
))} ))}
</ul> </ul>
<div dangerouslySetInnerHTML={{ __html: netKgFooterScript }} /> <NetKgTracker />
</div> </div>
<div className="footer__contacts"> <div className="footer__contacts">

View File

@ -0,0 +1,37 @@
"use client"
import React, { useEffect, useState } from 'react';
const NetKgTracker = () => {
const [imghref, setImghref] = useState('');
useEffect(() => {
var java="1.3";
var java1=""+"refer="+escape(document.referrer)+"&page="+escape(window.location.href);
document.cookie="astratop=1; path=/";
java1+="&c="+(document.cookie?"yes":"now");
java1+="&java="+(navigator.javaEnabled()?"yes":"now");
java1+="&razresh="+screen.width+'x'+screen.height+"&cvet="+
(((navigator.appName.substring(0,3)=="Mic"))?
screen.colorDepth:screen.pixelDepth);
java1+="&jscript="+java+"&rand="+Math.random();
setImghref("https://www.net.kg/img.php?id=7235&"+java1);
}, []);
return (
/*
<div>
<a href='https://www.net.kg/stat.php?id=7235&amp;fromsite=7235' target='_blank'>
<img src={imghref} alt='WWW.NET.KG' width='88' height='31' />
</a>
</div>
Enable NetKgTracker only in production
*/
<div/>
)
};
export default NetKgTracker;

948
yarn.lock

File diff suppressed because it is too large Load Diff