Skip to content

Commit 8922e30

Browse files
authored
(feat):add-google-tag-manager (#309)
* test gtm * pre-commit
1 parent de6dc78 commit 8922e30

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

package-lock.json

Lines changed: 25 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"nextra-theme-docs": "latest",
2626
"react": "^18.2.0",
2727
"react-dom": "^18.2.0",
28+
"react-gtm-module": "^2.0.11",
2829
"react-syntax-highlighter": "^15.5.0",
2930
"sharp": "^0.33.2",
3031
"toml": "^3.0.0",
@@ -38,6 +39,7 @@
3839
"@types/jest-expect-message": "^1.1.0",
3940
"@types/node": "18.11.10",
4041
"@types/react": "18.0.37",
42+
"@types/react-gtm-module": "^2.0.3",
4143
"@typescript-eslint/eslint-plugin": "^5.59.7",
4244
"@typescript-eslint/parser": "^5.59.7",
4345
"autoprefixer": "^10.4.14",

pages/_app.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import { WagmiConfig, createConfig } from "wagmi";
88
import { arbitrum, avalanche, mainnet, sepolia } from "wagmi/chains";
99
import { CosmosChains, GlobalContextProvider } from "../contexts/GlobalContext";
1010
import "../styles/styles.css";
11+
import TagManager from "react-gtm-module";
12+
13+
const tagManagerArgs = {
14+
gtmId: "GTM-MN3TWRGJ",
15+
};
1116

1217
const chains = [arbitrum, mainnet, avalanche, sepolia];
1318

@@ -31,6 +36,9 @@ export default function Nextra({ Component, pageProps }: NextraAppProps) {
3136
const [mounted, setMounted] = useState(false);
3237

3338
useEffect(() => setMounted(true), []);
39+
useEffect(() => {
40+
TagManager.initialize(tagManagerArgs);
41+
}, []);
3442

3543
// Make the global context available to every page.
3644
return (

0 commit comments

Comments
 (0)