From 962c14691ce2a8bee76c3f17bd22399ac77bbb6c Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Tue, 25 Mar 2014 14:55:33 +0100 Subject: [PATCH] Improved GA tracking --- _config.yml | 7 ++++++- _includes/footer.html | 4 ++-- _includes/scripts.html | 17 +++++++++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/_config.yml b/_config.yml index c401723..0228d6f 100644 --- a/_config.yml +++ b/_config.yml @@ -3,6 +3,7 @@ description: '[...] procedure calls may be usefully thought of as GOTO stat disqus_shortname: blog-kempkens-io #Your site's domain goes here. Leave localhost server or blank when working locally. url: http://blog.kempkens.io +source_url: https://github.com/nifoc/blog.kempkens.io # Owner/author information owner: @@ -28,7 +29,11 @@ background: # Analytics and webmaster tools stuff goes here google_analytics: UA-28082386-3 -google_analytics_site: blog.kempkens.io +google_analytics_linker: + 'daniel.xxx': + - blog.kempkens.io + 'blog.kempkens.io': + - daniel.xxx google_verify: # https://ssl.bing.com/webmaster/configure/verify/ownership Option 2 content= goes here bing_verify: diff --git a/_includes/footer.html b/_includes/footer.html index 093a377..ff6e497 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -1,4 +1,4 @@ - © {{ site.time | date: '%Y' }} {{ site.owner.name }}. Powered by Jekyll using the HPSTR Theme.
- Source on GitHub + © {{ site.time | date: '%Y' }} {{ site.owner.name }}. Powered by Jekyll using the HPSTR Theme. + {% if site.source_url %}
Source on GitHub{% endif %}
diff --git a/_includes/scripts.html b/_includes/scripts.html index 920696e..d3a84c4 100644 --- a/_includes/scripts.html +++ b/_includes/scripts.html @@ -9,8 +9,21 @@ 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 }}', '{{ site.google_analytics_site }}'); - ga('send', 'pageview'); + (function() { + var linkerOptions = {{ site.google_analytics_linker | jsonify }}; + var host = window.location.host; + + if (linkerOptions !== null) { + ga('create', '{{ site.google_analytics }}', host, 'auto', { + 'allowLinker': true + }); + ga('require', 'linker'); + ga('linker:autoLink', linkerOptions[host]); + } else { + ga('create', '{{ site.google_analytics }}', host); + } + ga('send', 'pageview'); + })(); {% endif %} {% if page.comments %}{% include disqus_comments.html %}{% endif %}