Skip to content

Commit c63f97c

Browse files
committed
add google tag manager for main page
1 parent 8e546cc commit c63f97c

4 files changed

Lines changed: 13 additions & 0 deletions

File tree

.env.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
REACT_APP_QUIZ_SERVER_URL=https://lis-dev.github.io/big5-data
22
REACT_APP_DEFAULT_LANG=en
3+
REACT_APP_GTM_ID=

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"kutty": "^0.5.2",
1717
"react": "^17.0.2",
1818
"react-dom": "^17.0.2",
19+
"react-ga4": "^1.4.1",
1920
"react-scripts": "^4.0.3",
2021
"typescript": "^4.1.2",
2122
"valtio": "^1.2.6",

src/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import App from './App'
55
import reportWebVitals from './reportWebVitals'
66
import { Base } from './components/Base'
77
import { ErrorBoundary } from './components/ErrorBoundary'
8+
import ReactGA from 'react-ga4'
9+
10+
if (process.env.REACT_APP_GTM_ID) {
11+
ReactGA.initialize(process.env.REACT_APP_GTM_ID)
12+
ReactGA.send('pageview')
13+
}
814

915
ReactDOM.render(
1016
<React.StrictMode>

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9406,6 +9406,11 @@ react-error-overlay@^6.0.9:
94069406
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
94079407
integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==
94089408

9409+
react-ga4@^1.4.1:
9410+
version "1.4.1"
9411+
resolved "https://registry.yarnpkg.com/react-ga4/-/react-ga4-1.4.1.tgz#6ee2a2db115ed235b2f2092bc746b4eeeca9e206"
9412+
integrity sha512-ioBMEIxd4ePw4YtaloTUgqhQGqz5ebDdC4slEpLgy2sLx1LuZBC9iYCwDymTXzcntw6K1dHX183ulP32nNdG7w==
9413+
94099414
react-is@^16.8.1:
94109415
version "16.13.1"
94119416
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"

0 commit comments

Comments
 (0)