Skip to content

Commit e71b000

Browse files
sr-dashkb107
authored andcommitted
Updated scripts for correctly using gtag. (alshedivat#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.
1 parent a7b91e9 commit e71b000

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

_includes/scripts.liquid

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@
216216
<!-- Analytics -->
217217
<!-- Global site tag (gtag.js) - Google Analytics -->
218218
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
219+
<script>
220+
window.dataLayer = window.dataLayer || [];
221+
function gtag() {
222+
dataLayer.push(arguments);
223+
}
224+
gtag('js', new Date());
225+
226+
gtag('config', '{{ site.google_analytics }}');
227+
</script>
219228
<script defer src="{{ '/assets/js/google-analytics-setup.js' | relative_url | bust_file_cache }}"></script>
220229
{% endif %}
221230

0 commit comments

Comments
 (0)