Closed StSaens closed 6 months ago
Hi,
Thanks for pointing this out. I am quite sure most of those sanitizations are done while WooCommerce processes the email address.
Have you tried to place an order entering an email address that doesn't fulfill any of those requirements?
Hi. Point 2 and 4 are for sure not done by woo.
Thanks!
v1.20 will be released tomorrow, although this code seems to me a low risk change, I will add it into either 1.20.1 or 1.21
@StSaens @duracelltomi how should be an empty email handled? Now even empty string is hashed and empty string does generate a hash, so I believe this is not correct too.
I have this in my "hotfixes":
add_filter( 'gtm4wp_compile_datalayer', function($dataLayer) {
if (empty(trim($dataLayer['customerBillingEmail']))) {
$dataLayer['customerBillingEmailHash'] = "";
}
return $dataLayer;
}, 99, 1 );
Partly done: https://github.com/duracelltomi/gtm4wp/commit/4aad7858a0a64196e586ccacd9a2b6ff5eb7414f
TODO:
I've added better normalization into the next version: https://github.com/duracelltomi/gtm4wp/commit/a08afa9b5bf3b8f107152b5dbc14db53d880db98
However I have doubts adding phone number formatting as it seems to be a more complex code that I though. I've found this library but adding this to GTM4WP would be a large addition for one specific feature: https://github.com/giggsey/libphonenumber-for-php
Currently, I think some sort of normalization should be added into WooCommerce itself so that all plugins can benefit from the results.
Great that the email formatting is implemented. Happy with that. Should be enough for most eCommerce shops.
With regards to the phone nr. That will mean that, unless the customer inputs it exactly right, Google won't be able to match that hash for enhanced conversion tracking. Maybe this should be clarified somewhere in gtm4wp docs.
@morvy customerBillingEmailHash is not the right variable to use.
Variables in orderData are filtered to prevent hashing of empty strings.
I will fix this with customerBillingEmailHash too
Hi, I glanced at some code changes you made for enhanced conversion reporting. As an FYI, you can't just hash the email and assume it's done. Google has (almost hidden for whatever reason) a few steps to do before it's hashed. See: https://developers.google.com/google-ads/api/docs/conversions/enhanced-conversions/web
Maybe you have implemented this. I only glanced at some changes superficially. I don't know why they haven't signaled this in various documents more clearly, but it is what it is.