From 82fdce66ce54797ecd8489bb0d150a871abcc6f3 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Tue, 6 Dec 2016 11:22:25 +0100 Subject: [PATCH] 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) {