I have added the following code to the header of the master page:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-000000000-0" ></script>
window.dataLayer = window.dataLayer || ;
gtag('js', new Date());
where UA-000000000-0 is my Google Analytics Tracking ID.
And Robohelp is giving me a parse error for the first line of the script saying invalid character s and underlining the s of the src. I tried adding it this way
<script src="https://www.googletagmanager.com/gtag/js?id=UA-000000000-0" async ></script>
(as I found a website that seemed to suggest that you add the async at the end) but then got Invalid character > underlining the > next to async.
I got this code from the Google Analytics website.
Try adding a forward slash after the closing double quote marks. I had something similar with Google Fonts.
Thank you very much Amebr, that worked!