无法将 Google 分析与 React.js 连接
Can't connect Google Analitycs with React.js
你好吗?我严重无法将 GA 与 React 连接起来,我很困惑,我看到 ID 连接器的所有视频都以 UA 开头,请帮助我
import './App.css';
// import Header from "../Header/header"
import Header2 from "../Header2/header"
import Footer from "../Footer/footer"
import Switch from "../Switch/switch"
import {BrowserRouter as Router} from "react-router-dom";
import React, {useEffect} from "react"
import ReactGa from "react-ga";
/**** Icons ****/
import { library } from '@fortawesome/fontawesome-svg-core'
import { fab, faFacebookSquare, faGoogle, faInstagramSquare, faWhatsappSquare} from '@fortawesome/free-brands-svg-icons'
import { fas, faBars, faIdCard, faGlobeAmericas, faCalendarAlt, faArrowUp} from '@fortawesome/free-solid-svg-icons'
library.add(fas, fab, faBars, faFacebookSquare, faInstagramSquare, faWhatsappSquare, faGoogle, faIdCard, faGlobeAmericas, faCalendarAlt, faArrowUp)
function App() {
useEffect(() => {
ReactGa.initialize('G-YZ9S63BMYY')
ReactGa.pageview(window.location.pathname)
}, [])
useEffect(() => {
console.log("hola", window.location.pathname)
})
return (
<Router>
<Header2 />
<React.StrictMode>
<Switch />
</React.StrictMode>
<Footer />
</Router>
);
}
export default App;
从现在开始感谢所有的人:)
您必须为 GA4 使用 React:https://www.npmjs.com/package/react-ga4
你好吗?我严重无法将 GA 与 React 连接起来,我很困惑,我看到 ID 连接器的所有视频都以 UA 开头,请帮助我
import './App.css';
// import Header from "../Header/header"
import Header2 from "../Header2/header"
import Footer from "../Footer/footer"
import Switch from "../Switch/switch"
import {BrowserRouter as Router} from "react-router-dom";
import React, {useEffect} from "react"
import ReactGa from "react-ga";
/**** Icons ****/
import { library } from '@fortawesome/fontawesome-svg-core'
import { fab, faFacebookSquare, faGoogle, faInstagramSquare, faWhatsappSquare} from '@fortawesome/free-brands-svg-icons'
import { fas, faBars, faIdCard, faGlobeAmericas, faCalendarAlt, faArrowUp} from '@fortawesome/free-solid-svg-icons'
library.add(fas, fab, faBars, faFacebookSquare, faInstagramSquare, faWhatsappSquare, faGoogle, faIdCard, faGlobeAmericas, faCalendarAlt, faArrowUp)
function App() {
useEffect(() => {
ReactGa.initialize('G-YZ9S63BMYY')
ReactGa.pageview(window.location.pathname)
}, [])
useEffect(() => {
console.log("hola", window.location.pathname)
})
return (
<Router>
<Header2 />
<React.StrictMode>
<Switch />
</React.StrictMode>
<Footer />
</Router>
);
}
export default App;
从现在开始感谢所有的人:)
您必须为 GA4 使用 React:https://www.npmjs.com/package/react-ga4