Open
Description
Hello.
In my React component, I have to get gtm-ID from another data which change many time. Each time this data changes, my component render. And each time component renders, function TagManager.initialize runs again, this create duplicate gtm scripts (as attached).
My code:
useEffect(() => {
if (data.gtm_id){
TagManager.initialize({
gtmId: data.gtm_id,
});
}
}, [data.gtm_id])
Could you please advise me how to avoid function TagManager.initialize() to run if it already run?
Thank you.
Metadata
Metadata
Assignees
Labels
No labels