From 13b2969bb853ca8399f1b1b06317a2bfb02c2919 Mon Sep 17 00:00:00 2001 From: Bruno Coelho <4brunu@users.noreply.github.com> Date: Thu, 3 May 2018 19:27:03 +0100 Subject: [PATCH] Add option to anonymize analytics ip address (#1636) * Add option to anonymize analytics ip address * Add option to anonymize analytics ip address in google tag --- _config.yml | 1 + _includes/analytics-providers/google-gtag.html | 2 +- _includes/analytics-providers/google-universal.html | 1 + _includes/analytics-providers/google.html | 3 +++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 104b2182..2afe7c0e 100644 --- a/_config.yml +++ b/_config.yml @@ -93,6 +93,7 @@ analytics: provider : false # false (default), "google", "google-universal", "custom" google: tracking_id : + anonymize_ip : # true, false (default) # Site Author diff --git a/_includes/analytics-providers/google-gtag.html b/_includes/analytics-providers/google-gtag.html index 31f2a696..16d0cf17 100644 --- a/_includes/analytics-providers/google-gtag.html +++ b/_includes/analytics-providers/google-gtag.html @@ -5,5 +5,5 @@ function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); - gtag('config', '{{ site.analytics.google.tracking_id }}'); + gtag('config', '{{ site.analytics.google.tracking_id }}', { 'anonymize_ip': {{ site.analytics.google.anonymize_ip | default: false }}}); diff --git a/_includes/analytics-providers/google-universal.html b/_includes/analytics-providers/google-universal.html index 10d65b2e..58d3e515 100644 --- a/_includes/analytics-providers/google-universal.html +++ b/_includes/analytics-providers/google-universal.html @@ -5,5 +5,6 @@ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', '{{ site.analytics.google.tracking_id }}', 'auto'); + ga('set', 'anonymizeIp', {{ site.analytics.google.anonymize_ip | default: false }}) ga('send', 'pageview'); diff --git a/_includes/analytics-providers/google.html b/_includes/analytics-providers/google.html index b591b995..99412b0e 100644 --- a/_includes/analytics-providers/google.html +++ b/_includes/analytics-providers/google.html @@ -1,6 +1,9 @@