Skip to content

Commit 8481051

Browse files
authored
add analytics (#45)
Co-authored-by: zeospec <zeospec@users.noreply.github.com>
1 parent 3d0a2b0 commit 8481051

2 files changed

Lines changed: 13 additions & 20 deletions

File tree

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ footer_img: '/assets/images/logo_footer.jpg'
99
post_default_img: '/assets/images/posts/bangpyperscover.jpg'
1010
baseurl: ""
1111
url: "https://bangalore.python.org.in"
12-
# google_analytics: ''
12+
google_analytics: 'G-2KWW473BLG'
1313
# disqus: ''
1414
# mailchimp-list: ''
1515

_layouts/default.html

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,28 +74,21 @@
7474
<link href="{{ site.baseurl }}/assets/css/main.css" rel="stylesheet">
7575

7676
<script src="{{ site.baseurl }}/assets/js/jquery.min.js"></script>
77+
78+
{% if site.google_analytics %}
79+
<!-- Global site tag (gtag.js) - Google Analytics -->
80+
<script async src="https://www.googletagmanager.com/gtag/js?id={{site.google_analytics}}"></script>
81+
<script>
82+
window.dataLayer = window.dataLayer || [];
83+
function gtag(){dataLayer.push(arguments);}
84+
gtag('js', new Date());
85+
86+
gtag('config', '{{site.google_analytics}}');
87+
</script>
88+
{% endif %}
7789

7890
</head>
7991

80-
{% if site.google_analytics %}
81-
<script>
82-
(function (i, s, o, g, r, a, m) {
83-
i['GoogleAnalyticsObject'] = r;
84-
i[r] = i[r] || function () {
85-
(i[r].q = i[r].q || []).push(arguments)
86-
}, i[r].l = 1 * new Date();
87-
a = s.createElement(o),
88-
m = s.getElementsByTagName(o)[0];
89-
a.async = 1;
90-
a.src = g;
91-
m.parentNode.insertBefore(a, m)
92-
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
93-
94-
ga('create', '{{site.google_analytics}}', 'auto');
95-
ga('send', 'pageview');
96-
</script>
97-
{% endif %}
98-
9992
{% capture layout %}{% if page.layout %}layout-{{ page.layout }}{% endif %}{% endcapture %}
10093

10194
<body class="{{ layout }}">

0 commit comments

Comments
 (0)