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:
parent
ac2b8db6b3
commit
13b2969bb8
4 changed files with 6 additions and 1 deletions
|
@ -93,6 +93,7 @@ analytics:
|
||||||
provider : false # false (default), "google", "google-universal", "custom"
|
provider : false # false (default), "google", "google-universal", "custom"
|
||||||
google:
|
google:
|
||||||
tracking_id :
|
tracking_id :
|
||||||
|
anonymize_ip : # true, false (default)
|
||||||
|
|
||||||
|
|
||||||
# Site Author
|
# Site Author
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
function gtag(){dataLayer.push(arguments);}
|
function gtag(){dataLayer.push(arguments);}
|
||||||
gtag('js', new Date());
|
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>
|
</script>
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
ga('create', '{{ site.analytics.google.tracking_id }}', 'auto');
|
ga('create', '{{ site.analytics.google.tracking_id }}', 'auto');
|
||||||
|
ga('set', 'anonymizeIp', {{ site.analytics.google.anonymize_ip | default: false }})
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var _gaq = _gaq || [];
|
var _gaq = _gaq || [];
|
||||||
_gaq.push(['_setAccount', '{{ site.analytics.google.tracking_id }}']);
|
_gaq.push(['_setAccount', '{{ site.analytics.google.tracking_id }}']);
|
||||||
|
{% if site.analytics.google.anonymize_ip == true %}
|
||||||
|
_gaq.push(['_gat._anonymizeIp']);
|
||||||
|
{% endif %}
|
||||||
_gaq.push(['_trackPageview']);
|
_gaq.push(['_trackPageview']);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
Loading…
Reference in a new issue