Skip to content

Commit b42c305

Browse files
added google analytics tracking 2
1 parent f83a136 commit b42c305

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

_layouts/default.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
<!DOCTYPE html>
22
<html lang="{{ site.lang | default: "en-US" }}">
33
<head>
4-
{% if site.google_analytics %}
5-
<!-- Global Site Tag (gtag.js) - Google Analytics -->
6-
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-107694606-1"></script>
7-
<script>
8-
window.dataLayer = window.dataLayer || [];
9-
function gtag(){dataLayer.push(arguments);}
10-
gtag('js', new Date());
11-
12-
gtag('config', 'UA-107694606-1');
13-
</script>
14-
{% endif %} <meta charset="UTF-8">
4+
<meta charset="UTF-8">
155

166
{% seo %}
177
<meta name="description" content="{{ page.description | default: site.description | default: site.github.project_tagline }}"/>
@@ -45,6 +35,17 @@ <h2 class="project-tagline">{{ site.description | default: site.github.project_t
4535
</footer>
4636
</section>
4737

38+
{% if site.google_analytics %}
39+
<script type="text/javascript">
40+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
41+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
42+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
43+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
44+
45+
ga('create', '{{ site.google_analytics }}', 'auto');
46+
ga('send', 'pageview');
47+
</script>
4848

49+
{% endif %}
4950
</body>
5051
</html>

0 commit comments

Comments
 (0)