-
Correcting the Href Path for React GA in a React App
Hey there! I ran into a small issue with my react app project where I’m using Google analytics. Here’s what my code looks like:
`javascript
import ReactGA from “react-ga4”;
import TagManager from “react-gtm-module”;useEffect(() => {
ReactGA.initialize(“G-xxxxx…”);
ReactGA.send(“pageview”);
TagManager.initialize({
gtmId: “GTM-x”xxxx…
});
}, []);<a
href={${window.location.protocol}//${domain}
}
target=”_blank”
rel=”noreferrer noopener”>
{${window.location.protocol}//${domain}
}`
But when I browse, the link href appears like this:
`html
https://test.com
`
I can’t figure out why it happens. Hoping you might help me fixing it. Ideally, I want it like this:
`html
https://test.com
`
Log in to reply.