Here is my problem. I am using google analytics with wordpress. I tried setting up Google Analytics for my site using a plugin called Google Analytics Dashboard for WP (GADWP). This plugin generated a piece of Google analytics that looks similar to the one described in the question:
<script> (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','ga'); ga('create', 'UA-475021xx-x', 'auto'); ga('send', 'pageview'); </script>
However, in the Google Analytics console, the proposed snippet looked like this:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-110984887-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-475021xx-x'); </script>
Gtag.js seems to be the new Google Analytics snippet format. So I disabled this wordpress plugin, and I manually added the script suggested by Google Analytics to the page.
source share