duracelltomi / gtm4wp

Google Tag Manager plugin for WordPress
https://gtm4wp.com/
GNU General Public License v3.0
146 stars 96 forks source link

DataLayer not compliant with Google specifications. #348

Open Tom-nn opened 5 months ago

Tom-nn commented 5 months ago

Hello. Very cool plugin, but auditing the dataLayer I discovered that a part is not compatible with the Google specification.

view_item_list - price not numeric select_item - price is not numeric view_item - value and price are not numeric, quantity is missing, instead of variant should be item_variant add_to_cart - value, price and quantity are not numeric, instead of variant should be item_variant remove_from_cart - price and quantity are not numeric event: "view_cart" is at the end, after ecommerce: and should be before event: "begin_checkout" is at the end, after ecommerce: a should be before purchase - affiliation should be in items not in ecommerce (and affiliation is missing in previous steps)

Coupons are not working, making the price inconsistent on the purchase path and the value wrong: view_cart - coupon and discount are missing in items remove_from_cart - coupon and discount are missing in items begin_checkout - coupon is missing in ecommerce and items, discount is missing in items add_shipping_info - missing coupon in ecommerce and items, missing discount in items add_payment_info - coupon is missing in ecommerce and items, discount is missing in items purchase - missing coupon and discount in items

Tom-nn commented 4 months ago

While auditing the analytics implemented with the plugin, I found another mistake, but in the documentation rather than in the scripts. In the instructions for enabling Enhanced Conversion for Google Ads (https://gtm4wp.com/google-tag-manager-for-woocommerce/enhanced-conversions-for-google-ads-with-woocommerce-how-to-setup) is to provide variables with hashed values in the “Email”, “Phone”, “First Name” and “Last Name” fields. But according to Google's documentation (https://support.google.com/google-ads/answer/13262500?sjid=15788915886387418000-EU#zippy=%2Cidentify-and-define-your-enhanced-conversions-variables), Key Name: “email”, “phone_number”, “address.first_name” and “address.last_name” are explicit values. Entering hashed values in these fields will result in Google's side hashing values that have already been hashed, so the match will not work.

duracelltomi commented 3 months ago

Thanks for your findings

About for first post: do you have any specific case where this resulted in bad data collection? (I am using this plugin on several ecommerce sites without issues)

About your second finding: Google can detect whether they are getting hashed data or not and prevent the data from being double hashed.

Tom-nn commented 2 days ago

I have not noticed the negative effects of some numeric values not being a numeric variable. I just noticed that it is not in accordance with Google's specification and I don't know what effects it might have. On the other hand, the lack of coupon and discount limits the possibility of defining events related to it. The fact that somewhere instead of variant should be item_variant, also causes problems in pulling consistent data throughout the purchase path. Thank you for the information regarding data hashing.