I need SEO help. I want to ask if these scripts number 1 and 2 does the same thing. The number 1 is located in the <head>
while the number 2 is located just before the </body>
tag. Because I think these 2 scripts function similarly and skews my website traffic data. Can someone please help enlighten me. Thank you.
1.)
<script async src="/wp-content/google/solarwhiz_tracking.js"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-20229862-2');
</script>
2.)
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','gaplusu');
function gaplus_track() {
gaplusu('create', 'UA-20229862-2', 'auto');
gaplusu('send', 'pageview');
}
gaplus_track();
</script>
And when I look at the tracking code in our analytics admin, the code is like this
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-20229862-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-20229862-2');
</script>
What if I replaced the number 1.) with this code? will my historical data be erased too?
Thanks in advance.
just replace the number 1, your data not be erase, if google data analytisc stop tracking you can previos number 1. Trust me, your data will normal