I am working on js file, within which I want to call google analytics methods. I only have access to the js file(s) and not html pages. I can create a new js file if need be.
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
</script>
is there a way I can do the above script tag equivalent within a js file, or do in another js file and import it?