Update Google Analytics tracking code.

This commit is contained in:
James Cole
2018-09-10 20:21:39 +02:00
parent 0bf5c6ee3d
commit b30445a5f3
3 changed files with 21 additions and 43 deletions

View File

@@ -200,21 +200,14 @@
{% block scripts %}{% endblock %}
{% if env('ANALYTICS_ID','') != '' %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ env('ANALYTICS_ID', 'XXX-XX-X') }}"></script>
<script>
// send pageview
(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', '{{ env('ANALYTICS_ID', 'XXX-XX-X') }}', {'siteSpeedSampleRate': 100});
ga('send', 'pageview');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ env('ANALYTICS_ID', 'XXX-XX-X') }}');
</script>
{% endif %}

View File

@@ -42,21 +42,14 @@
<script src="js/app.js?v={{ FF_VERSION }}" type="text/javascript"></script>
{% if env('ANALYTICS_ID','') != '' %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ env('ANALYTICS_ID', 'XXX-XX-X') }}"></script>
<script>
// send pageview
(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', '{{ env('ANALYTICS_ID', 'XXX-XX-X') }}', {'siteSpeedSampleRate': 100});
ga('send', 'pageview');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ env('ANALYTICS_ID', 'XXX-XX-X') }}');
</script>
{% endif %}
</body>

View File

@@ -50,23 +50,15 @@
</div>
<script src="js/app.js?v={{ FF_VERSION }}" type="text/javascript"></script>
<script type="text/javascript" src="js/ff/guest.js?v={{ FF_VERSION }}"></script>
{% if env('ANALYTICS_ID','') != '' %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ env('ANALYTICS_ID', 'XXX-XX-X') }}"></script>
<script>
// send pageview
(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', '{{ env('ANALYTICS_ID', 'XXX-XX-X') }}', {'siteSpeedSampleRate': 100});
ga('send', 'pageview');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ env('ANALYTICS_ID', 'XXX-XX-X') }}');
</script>
{% endif %}
</body>