Skip to content

Commit

Permalink
Merge pull request #39 from italia/add-analytics
Browse files Browse the repository at this point in the history
Added analytics tracking
  • Loading branch information
pdavide authored Mar 2, 2018
2 parents 07eb989 + c9b041b commit 3e2ddcc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
4 changes: 3 additions & 1 deletion docs-italia-theme/data/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ privacy_link: https://developers.italia.it/it/privacy-policy
gov_logo: https://teamdigitale.governo.it/images/loghi/governo.svg
partner_logo: https://teamdigitale.governo.it/images/loghi/dt-logo.svg
pill: beta
default_language: it
default_language: it
piwik: 9966c07e-e545-4281-8558-a5ad707c5c52
google_analytics: UA-96140462-1
2 changes: 2 additions & 0 deletions docs-italia-theme/layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
{% include 'layouts/scrolltop.html' %}
{% include 'layouts/footer.html' %}
{% include 'layouts/scripts.html' %}
{% include 'layouts/google-analytics.html' %}
{% include 'layouts/piwik.html' %}

{%- block footer %}{% endblock %}
</body>
Expand Down
20 changes: 6 additions & 14 deletions docs-italia-theme/layouts/google-analytics.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<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', 'https://www.google-analytics.com/analytics.js', 'ga');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

ga('create', '{{ site.google_analytics }}', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
gtag('config', '{{ site.google_analytics }}', { 'anonymize_ip': true });
</script>
1 change: 0 additions & 1 deletion docs-italia-theme/layouts/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google-site-verification" content="8IbTZ-PnSdvOnC8S4q-wjSiZ2B-90cVugO04xMu6vug" />

<title>{{ title|striptags|e }}{{ titlesuffix }}</title>

Expand Down
16 changes: 16 additions & 0 deletions docs-italia-theme/layouts/piwik.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//italia.piwikpro.com/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '{{ site.piwik }}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//italia.piwikpro.com/piwik.php?idsite={{ site.piwik }}" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->

0 comments on commit 3e2ddcc

Please sign in to comment.