data_layer
entries is being sent empty from the site. While we’re unsure if this is directly related to the WooCommerce integration, we believe it may be contributing to the inaccurate data collection.Our primary concern is the discrepancy in the data when the “Add to Cart” action is triggered. This inconsistency is distorting our reports and impairing our data-driven decision-making process.
We need your assistance with:
data_layer
is logging multiple products instead of just the one added to the cart.data_layer
entry and determining whether this is related to the WooCommerce functionality or its integration with the GTM4WP plugin.We would greatly appreciate your prompt attention to this matter and any guidance you can provide to help us resolve these issues.
Best regards,
]]>data_layer
entries being sent from the website is empty. While we’re not certain if this is related to the main issue, we believe it could be contributing to the inaccurate data collection.Our primary concern is the discrepancy in the data when the “Add to Cart” button is clicked. This inconsistency is skewing our reports and affecting data-driven decisions.
We need your assistance with:
data_layer
is recording multiple products instead of only the product added to the cart.data_layer
entries is empty and determining if this is related to the overall issue.We appreciate your prompt attention to this matter and look forward to your guidance on resolving these issues.
Best regards
]]>Please fix this.
]]>The other events I tested are OK. There is some way to make it work?
Thanks for the nice plugin, best regards, Diego.
]]>We have been using the plugin for a while. It used to work well. Thanks for that.
But not for a while. We tried a lot to avoid contacting support unnecessarily.
The problem is that some events are no longer transferred to Google Analytics, e.g. add_to_cart.
What we notice is that GTM4WP doesn’t listen to WooCommerce’s jQuery frontend events, but simply to plain js click-listener.
This means that ajax_add_to_cart events are not processed by GTM4WP because they are usually stopped by plugins or themes via e.preventDefault().
If the plugin listened to jQuery.on(added_to_cart, ..) it would probably work fine again.
I read on GitHub that you want to avoid jQuery events because not all users use ajax_add_to_cart.
Probably not all users use this function. Correctly. On the other hand, excluding many users who use this function is probably not helpful either.
It would probably make sense to support both approaches. I assume that this can also be possible without a complete rewrite.
For example, there could be a simple checkbox in the plugin settings that sets a JS variable for your frontend script. This variable can contain the information as to whether the jQuery events should be listened to. If so, then try something like this in the frontend js-code:
if(window.jQuery && gtm4p_args.isAJAXAddToCartEnabled) {
jQuery.on('added_to_cart', (thisbutton, data)=>{
// get eventTarget from thisbutton
handleProductDetailPageAddToCart(eventTarget)
});
} else {
document.addEventListener('click', (event)=>{
// get eventTarget from e.target
handleProductDetailPageAddToCart(eventTarget)
});
}
function handleProductDetailPageAddToCart(eventTarget){
// do calulcations + send event - like the code is already doing it
// ....
}
The main effort should probably be rewriting the currently used inline handlers into named functions and adding the if conditions before registering the eventListeners.
According to GitHub, it also affects other users and you should be aware of it.
(In the long term, server-side tracking could perhaps also be an alternative in order not to have to support too many approaches. Especially when FSE finds its way into WooCommerce and another front-end approach may need to be supported. However, I don’t know whether all geodata can be transmitted correctly to Google. Probably too much effort for the time being anyway.)
How do you think we can solve the problem quickly?
]]>This issue has also on home page when click select options button (It redirects to the product page. Does not adding to cart yet.)
]]>How can I resolve this issue?
]]>I have this case with multisite and woocommerce, where they sell the same product through different sites, hence I want to use the same SKU for all. I ticked the box for Use SKU instead of ID and it works well on begin_checkout and other checkout related events. It also works on the view_item, however when the add_to_cart is pushed the datalayer item_id changes from SKU string back to the ID number – so my GA4 reporing of view_item to add_to_cart to purchase is getting messed up.
Looking inside the code – this condition somehow does not apply to add_to_cart data?
'id': gtm4wp_use_sku_instead ? dom_productdata.getAttribute( 'data-gtm4wp_product_sku' ) : dom_productdata.getAttribute( 'data-gtm4wp_product_id' )
thanks
]]>How can we fix this?
]]>