CMS Development

anujladia
Member

CTA embed in React component not tracking the analytics

Hi,

I embedded the CTA code in my React application with some hardship, but now once done I am unable to see the analytics in my HubSpot dashboard.

I wanted to know if I was doing something wrong in the way I am embedding the code.

Sharing the code for the how I have implemented the embed code insertion.

 

useEffect(() => {
const script = document.createElement("script");
document.body.appendChild(script);
 
script.addEventListener("load", () => {
if (window.hbspt) {
window.hbspt.cta.load(<portal-id>, <cta-id>, {})
}
});
}, []);
 
In the return function, I am rendering the HTML of the embed code.
 
The button is getting visible, but the views or clicks are not being counted.
0 Upvotes
2 Replies 2
neobats
Participant

CTA embed in React component not tracking the analytics

Hey @anujladia,

 

Any chance you were able to get this working? I'm having trouble with any of the clicks or redirects working with our CTA in our React app.

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

CTA embed in React component not tracking the analytics

Hey @anujladia,

 

In order for me to further troubleshoot this, could you share with me the page url that the button is on?

 

0 Upvotes