My default index html like this :
<html>
<head>
<meta name="google-site-verification" content="****************" />
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-7**4*7***"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-7**4*7***');
</script>
</head>
<body>
<script src="/Content/assets/script/combined.min.js" type="text/javascript"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-*4**0**6-*"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-*4**0**6-*');
</script>
</body>
</html>
So I using google tag manager
But I want to move the script inline js to the external js file (combined.min.js). So there is no inline js in the default html. This is to optimize my website
Other than that I also want to change the call js. So I want to call the js file from the folder. Not online. So like this :
For example :
I want to change to be like this :
So I copied the contents of the file to my folder
So the result like this :
<html>
<head>
<meta name="google-site-verification" content="****************" />
<script async src="/Content/assets/script/gtag-aw.min.js"></script>
</head>
<body>
<script src="/Content/assets/script/combined.min.js" type="text/javascript"></script>
<script async src="/Content/assets/script/gtag-ua.min.js"></script>
</body>
</html>
Can I do it like that? Or there is a better way?
Update :
I made combine.min.js like this :
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-7**4*7***');
...
/* some javascript files, for example jquery, jquery ui, custom js and others */
...
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-*4**0**6-*');
What do you think?