Updated scripts for correctly using gtag. (#2962)
Implementation of Google tag ID to correctly getting tracked requires further modification in addition to the one line script in the `_includes/scripts.liquid` file as ``` <script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', '{{ site.google_analytics }}'); </script> ``` I have made the changes and tested it out on my personal webpage to ensure the tracking in analytics dashboard.
This commit is contained in:
parent
caf9976175
commit
beeff21ecd
@ -216,6 +216,15 @@
|
||||
<!-- Analytics -->
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', '{{ site.google_analytics }}');
|
||||
</script>
|
||||
<script defer src="{{ '/assets/js/google-analytics-setup.js' | relative_url | bust_file_cache }}"></script>
|
||||
{% endif %}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user