diff --git a/_includes/head-custom-google-analytics.html b/_includes/head-custom-google-analytics.html new file mode 100644 index 0000000000..8a3ae5c9ca --- /dev/null +++ b/_includes/head-custom-google-analytics.html @@ -0,0 +1,10 @@ +{% if site.google_analytics %} + <script> + (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', '{{ site.google_analytics }}', 'auto'); + ga('send', 'pageview'); + </script> +{% endif %} diff --git a/_includes/head-custom.html b/_includes/head-custom.html new file mode 100644 index 0000000000..f7187e79e5 --- /dev/null +++ b/_includes/head-custom.html @@ -0,0 +1,9 @@ +<!-- start custom head snippets, customize with your own _includes/head-custom.html file --> + +<!-- Setup Google Analytics --> +{% include head-custom-google-analytics.html %} + +<!-- You can set your favicon here --> +<!-- link rel="shortcut icon" type="image/x-icon" href="{{ '/favicon.ico' | relative_url }}" --> + +<!-- end custom head snippets --> diff --git a/_layouts/default.html b/_layouts/default.html index e2bfab0f75..1b34eb086d 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -13,6 +13,7 @@ <![endif]--> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> + {% include head-custom.html %} </head> <body> @@ -51,16 +52,5 @@ <h1>{{ page.title | default: site.title | default: site.github.repository_name } <p><small>Hosted on GitHub Pages — Theme by <a href="https://twitter.com/mattgraham">mattgraham</a></small></p> </footer> </div> - - {% if site.google_analytics %} - <script> - (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', '{{ site.google_analytics }}', 'auto'); - ga('send', 'pageview'); - </script> - {% endif %} </body> </html>