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
This commit is contained in:
Bruno Coelho 2018-05-03 19:27:03 +01:00 committed by Michael Rose
parent ac2b8db6b3
commit 13b2969bb8
4 changed files with 6 additions and 1 deletions

View file

@ -93,6 +93,7 @@ analytics:
provider : false # false (default), "google", "google-universal", "custom"
google:
tracking_id :
anonymize_ip : # true, false (default)
# Site Author

View file

@ -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 }}});
</script>

View file

@ -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');
</script>

View file

@ -1,6 +1,9 @@
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ site.analytics.google.tracking_id }}']);
{% if site.analytics.google.anonymize_ip == true %}
_gaq.push(['_gat._anonymizeIp']);
{% endif %}
_gaq.push(['_trackPageview']);
(function() {