<script>
    if (navigator.userAgent.indexOf('Google Page Speed Insights') === -1) {
        var TRACKING_ID = 'UA-108806299-1';

        var gtagElement = document.createElement('script');

        gtagElement.async = true;
        gtagElement.src = 'https://www.googletagmanager.com/gtag/js?id=' + TRACKING_ID;

        var scriptElements = document.getElementsByTagName('script');
        var lastScriptElement = scriptElements[scriptElements.length - 1];

        lastScriptElement.parentNode.insertBefore(gtagElement, lastScriptElement.nextSibling);

        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }

        gtag('js', new Date());
        gtag('config', TRACKING_ID);
    }
</script>

<script>
    (function (document, trackingId) {
        if (navigator.userAgent.indexOf('Google Page Speed Insights') === -1) {
            var gtagElement = document.createElement('script');

            gtagElement.src = 'https://www.googletagmanager.com/gtagElementag/js?id=' + trackingId;
            gtagElement.async = true;

            var firstScriptElement = document.scripts[0];

            firstScriptElement.parentNode.insertBefore(gtagElement, firstScriptElement);

            window.dataLayer = window.dataLayer || [];

            function gtag() {
                dataLayer.push(arguments);
            }

            gtag('js', new Date());
            gtag('config', trackingId);
        }
    }(document, 'UA-108806299-1'));
</script>

Optimize GA script loading snippet
Optimize GA script loading snippet
