I have the following Google Analytics (gtag) code to be added in my React project. I am trying to add it in render() method. But its not working. How to resolve it. Thanks.
<script async src="https://www.googletagmanager.com/gtag/js?id=#######"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '#########');
</script>