From 82fdce66ce54797ecd8489bb0d150a871abcc6f3 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Tue, 6 Dec 2016 11:22:25 +0100 Subject: [PATCH 1/4] remove personal data from url before sending to GA --- themes/site/header.tpl | 25 +++++++++++++++++++++++-- themes/site_mobile/header.tpl | 24 ++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/themes/site/header.tpl b/themes/site/header.tpl index cb6986a3..ce7c375e 100755 --- a/themes/site/header.tpl +++ b/themes/site/header.tpl @@ -157,7 +157,18 @@ {/literal}{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}{literal} // send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation' - ga('send', 'pageview'); + + var re = new RegExp("([?&])(email=)[^&#]*", "g"); + if (document.location.href.match(re)) { + // remove personal data from url before sending to GA + url = window.location.search.replace(re, '$1'); + var page = window.location.pathname+url; + console.log(page); + ga('send', 'pageview', page); + } else { + ga('send', 'pageview'); + } + {/literal}{/if}{literal} function onStepComplete(stepNumber, option, redirect, form) { @@ -264,7 +275,17 @@ {/literal}{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}{literal} // send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation' - ga('send', 'pageview'); + + var re = new RegExp("([?&])(email=)[^&#]*", "g"); + if (document.location.href.match(re)) { + // remove personal data from url before sending to GA + url = window.location.search.replace(re, '$1'); + var page = window.location.pathname+url; + console.log(page); + ga('send', 'pageview', page); + } else { + ga('send', 'pageview'); + } {/literal}{/if}{literal} function onStepComplete(stepNumber, option, redirect, form) { diff --git a/themes/site_mobile/header.tpl b/themes/site_mobile/header.tpl index 8bd47875..2109c87d 100755 --- a/themes/site_mobile/header.tpl +++ b/themes/site_mobile/header.tpl @@ -163,7 +163,17 @@ {/literal}{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}{literal} // send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation' - ga('send', 'pageview'); + + var re = new RegExp("([?&])(email=)[^&#]*", "g"); + if (document.location.href.match(re)) { + // remove personal data from url before sending to GA + url = window.location.search.replace(re, '$1'); + var page = window.location.pathname+url; + console.log(page); + ga('send', 'pageview', page); + } else { + ga('send', 'pageview'); + } {/literal}{/if}{literal} function onStepComplete(stepNumber, option, redirect, form) { @@ -269,7 +279,17 @@ {/literal}{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}{literal} // send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation' - ga('send', 'pageview'); + + var re = new RegExp("([?&])(email=)[^&#]*", "g"); + if (document.location.href.match(re)) { + // remove personal data from url before sending to GA + url = window.location.search.replace(re, '$1'); + var page = window.location.pathname+url; + console.log(page); + ga('send', 'pageview', page); + } else { + ga('send', 'pageview'); + } {/literal}{/if}{literal} function onStepComplete(stepNumber, option, redirect, form) { From 22d5994ee472a8251a67d07041a7e872961dcbb7 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Tue, 6 Dec 2016 11:48:56 +0100 Subject: [PATCH 2/4] remove console log --- themes/site/header.tpl | 1 - themes/site_mobile/header.tpl | 1 - 2 files changed, 2 deletions(-) diff --git a/themes/site/header.tpl b/themes/site/header.tpl index ce7c375e..421871a3 100755 --- a/themes/site/header.tpl +++ b/themes/site/header.tpl @@ -281,7 +281,6 @@ // remove personal data from url before sending to GA url = window.location.search.replace(re, '$1'); var page = window.location.pathname+url; - console.log(page); ga('send', 'pageview', page); } else { ga('send', 'pageview'); diff --git a/themes/site_mobile/header.tpl b/themes/site_mobile/header.tpl index 2109c87d..700e9507 100755 --- a/themes/site_mobile/header.tpl +++ b/themes/site_mobile/header.tpl @@ -285,7 +285,6 @@ // remove personal data from url before sending to GA url = window.location.search.replace(re, '$1'); var page = window.location.pathname+url; - console.log(page); ga('send', 'pageview', page); } else { ga('send', 'pageview'); From a509d4f0abd6afe05599daa5003871c0e0388e7b Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Tue, 6 Dec 2016 11:53:34 +0100 Subject: [PATCH 3/4] remove personal data in ga module --- modules/ganalytics/header.tpl | 12 +++++++++++- themes/site/header.tpl | 1 - themes/site_mobile/header.tpl | 1 - 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/ganalytics/header.tpl b/modules/ganalytics/header.tpl index dbbebfc7..8de3fc59 100755 --- a/modules/ganalytics/header.tpl +++ b/modules/ganalytics/header.tpl @@ -45,7 +45,17 @@ 'shipping': '{$trans.shipping}', // Shipping (currency). }); - ga('send', 'pageview'); + {literal} + var re = new RegExp("([?&])(email=)[^&#]*", "g"); + if (document.location.href.match(re)) { + // remove personal data from url before sending to GA + url = window.location.search.replace(re, '$1'); + var page = window.location.pathname+url; + ga('send', 'pageview', page); + } else { + ga('send', 'pageview'); + } + {/literal} {/if} {/if} diff --git a/themes/site/header.tpl b/themes/site/header.tpl index 421871a3..d3591645 100755 --- a/themes/site/header.tpl +++ b/themes/site/header.tpl @@ -163,7 +163,6 @@ // remove personal data from url before sending to GA url = window.location.search.replace(re, '$1'); var page = window.location.pathname+url; - console.log(page); ga('send', 'pageview', page); } else { ga('send', 'pageview'); diff --git a/themes/site_mobile/header.tpl b/themes/site_mobile/header.tpl index 700e9507..93a28645 100755 --- a/themes/site_mobile/header.tpl +++ b/themes/site_mobile/header.tpl @@ -169,7 +169,6 @@ // remove personal data from url before sending to GA url = window.location.search.replace(re, '$1'); var page = window.location.pathname+url; - console.log(page); ga('send', 'pageview', page); } else { ga('send', 'pageview'); From 655a7515d733c821da141781e3cb627e4b4b24dc Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Tue, 6 Dec 2016 12:07:23 +0100 Subject: [PATCH 4/4] remove other personal datas --- modules/ganalytics/header.tpl | 8 ++++++-- themes/site/header.tpl | 16 ++++++++++++---- themes/site_mobile/header.tpl | 16 ++++++++++++---- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/modules/ganalytics/header.tpl b/modules/ganalytics/header.tpl index 8de3fc59..cd3dfe34 100755 --- a/modules/ganalytics/header.tpl +++ b/modules/ganalytics/header.tpl @@ -47,9 +47,13 @@ {literal} var re = new RegExp("([?&])(email=)[^&#]*", "g"); - if (document.location.href.match(re)) { + var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g"); + var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g"); + if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) { // remove personal data from url before sending to GA - url = window.location.search.replace(re, '$1'); + url = window.location.search.replace(re, '$1$2'); + url = url.replace(re2, '$1$2'); + url = url.replace(re3, '$1$2'); var page = window.location.pathname+url; ga('send', 'pageview', page); } else { diff --git a/themes/site/header.tpl b/themes/site/header.tpl index d3591645..94131e06 100755 --- a/themes/site/header.tpl +++ b/themes/site/header.tpl @@ -159,9 +159,13 @@ // send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation' var re = new RegExp("([?&])(email=)[^&#]*", "g"); - if (document.location.href.match(re)) { + var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g"); + var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g"); + if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) { // remove personal data from url before sending to GA - url = window.location.search.replace(re, '$1'); + url = window.location.search.replace(re, '$1$2'); + url = url.replace(re2, '$1$2'); + url = url.replace(re3, '$1$2'); var page = window.location.pathname+url; ga('send', 'pageview', page); } else { @@ -276,9 +280,13 @@ // send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation' var re = new RegExp("([?&])(email=)[^&#]*", "g"); - if (document.location.href.match(re)) { + var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g"); + var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g"); + if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) { // remove personal data from url before sending to GA - url = window.location.search.replace(re, '$1'); + url = window.location.search.replace(re, '$1$2'); + url = url.replace(re2, '$1$2'); + url = url.replace(re3, '$1$2'); var page = window.location.pathname+url; ga('send', 'pageview', page); } else { diff --git a/themes/site_mobile/header.tpl b/themes/site_mobile/header.tpl index 93a28645..6b0a0780 100755 --- a/themes/site_mobile/header.tpl +++ b/themes/site_mobile/header.tpl @@ -165,9 +165,13 @@ // send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation' var re = new RegExp("([?&])(email=)[^&#]*", "g"); - if (document.location.href.match(re)) { + var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g"); + var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g"); + if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) { // remove personal data from url before sending to GA - url = window.location.search.replace(re, '$1'); + url = window.location.search.replace(re, '$1$2'); + url = url.replace(re2, '$1$2'); + url = url.replace(re3, '$1$2'); var page = window.location.pathname+url; ga('send', 'pageview', page); } else { @@ -280,9 +284,13 @@ // send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation' var re = new RegExp("([?&])(email=)[^&#]*", "g"); - if (document.location.href.match(re)) { + var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g"); + var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g"); + if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) { // remove personal data from url before sending to GA - url = window.location.search.replace(re, '$1'); + url = window.location.search.replace(re, '$1$2'); + url = url.replace(re2, '$1$2'); + url = url.replace(re3, '$1$2'); var page = window.location.pathname+url; ga('send', 'pageview', page); } else {