Created
April 6, 2025 21:30
-
-
Save isocroft/cb735e28e8824f1257867e1e5ad00048 to your computer and use it in GitHub Desktop.
Google tag manager component for ReactJS in NextJS RSC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use client" | |
| import { useEffect } from "react"; | |
| import TagManager from "react-gtm-module"; | |
| export default function GoogleTagManager () { | |
| useEffect(() => { | |
| const gtmId = process.env.NEXT_PUBLIC_GTM_ID; | |
| if (gtmId) { | |
| TagManager.initialize({ gtmId }); | |
| } | |
| }, []); | |
| return null; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment