duracelltomi / gtm4wp

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

Add to cart not firing for grouped products list #256

Open lucspe opened 1 year ago

lucspe commented 1 year ago

Hi, I am having trouble with grouped products list (so a page which shows like the sample GTM4WP dev site: https://woo.gtm4wp.dev/product/grouped-sample-product).

When add to cart is clicked, I would expect that an add_to_cart event is fired and the contents of the list are passed (this is what happens when using other similar plugins). However in GTM4WP it doesn't seem to work.

To make sure, I even tried changing default theme to StoreFront and removing other plugins other than WooCommerce and GTM4WP.

Any suggestions on how I could further investigage the issue?

duracelltomi commented 1 year ago

Hi,

Perhaps I just did not understand the question correctly, but this is what I see happening on the mentioned dev site:

image

Or this is only not working on your site?

lucspe commented 1 year ago

Hi Tamas,

Thanks for replying.

Indeed i linked the page on dev site only as a reference, apologies for the misunderstanding.

The issue appears on my site. It records only view item and view item list when the form is submitted.

I tried with different GTM plugins and it works as expected so i am a bit lost on what to do next to try and find what is that is missing for GTM4WP (which is what i would prefer to use as it is by far the most comprehensive plugin for this) to fire the event.

duracelltomi commented 1 year ago

Hi,

Please give me more context, I am not able to help without seeing the issue somewhere. Most possible reasons are not proper HTML structure (but you said it is not working with Storefront either) or the lack to some important WooCommerce hooks (again, with Storefront, that should not be an issue)

lucspe commented 1 year ago

Hi Tamas,

Thanks for replying.

In order to try and reproduce the issue I have:

Unless I am unable to interpret the data in GTM Tag Assistant and GA4 DebugView correctly (never underestimate the "human error" :-) ) it seems to me that for grouped products the add_to_cart event doesn't fire. Everything else works fine.

This is the test site, btw:

https://demostore.perivor.com

duracelltomi commented 1 year ago

I've found the bug: when you select to use SKU instead of the internal product ID, this feature was broken. This should fix it: https://github.com/duracelltomi/gtm4wp/commit/5ecb4c13e510a4427a081130da76bca14eff1f6b

Floyd-Schramm commented 1 year ago

Hi.

I've got a similar problem. The gtm4wp.addProductToCartEEC event fires correctly when adding a single product to the cart, but nothing happens when I try to add products from a grouped product to the cart. I also have no luck getting the begin checkout event to fire, but that's another topic :/

single product -> https://fmp-equipment.de/produkt/001_010/ grouped product -> https://fmp-equipment.de/produkt/001/

What I've already done:

I hope you can help me here, because I was trying for a few hours already, hoping to get this to work. Apart from these problems I really like the plugin and documentation so far!

EDIT: Begin checkout event is now working. The checkout plugin Fluid Checkout uses a custom header and footer, so the manually added GTM code from my header and body weren't injected there. This is now fixed.

Floyd-Schramm commented 1 year ago

@duracelltomi @lucspe any updates on the topic?

duracelltomi commented 1 year ago

@Floyd-Schramm do you have a testing version of the site where site caching and optimizations can be turned off?

From what i can see the problem is related to what has been fixed in 1.17: https://github.com/duracelltomi/gtm4wp/releases

Finally I will have time tomorrow to release it on WP.org AND follow first reactions.

Floyd-Schramm commented 1 year ago

@duracelltomi I currently have no site without caching/optimizations but I could try to set one up for testing.

I have not gotten an update for the GTM4WP plugin through WP so I manually installed the new version and now the add-to-cart event fires but with incorrect quantity data.

These are the products I added to the cart: image

And this is the data GTM got from the plugin: image

As you can see, GTM got the info that I added all available product versions to the cart, which is incorrect (I only added 2 and not all 6 versions). Do you have any idea how to fix this?

In addition, I now have the plugin installed two times and cant seem to uninstall the older version: image

Floyd-Schramm commented 1 year ago

@duracelltomi this issue is still not resolved!

duracelltomi commented 1 year ago

Sorry, I was cleaning up and accidentally closed this ticket.

brthmrk commented 3 months ago

Any solutions yet?

duracelltomi commented 2 months ago

The code samples earlier were from version v1.17 and related to the old version of the ecommerce data layer that has been already removed. Are you sure you still experience the issue? Can you reproduce the issue on https://woo.gtm4wp.dev/?

brthmrk commented 2 months ago

Still got the issue on: https://www.rentyourmac.com/cloud/product/additional-software-final-cut-pro-x/ And: https://www.rentyourmac.com/cloud/product/mac-mini-m2-2023/

Met vriendelijke groet,

[image: brthmrk werknemer] Jim Servaas Eigenaar [image: phone icon] 0683234700 [image: email icon] @.*** [image: location icon] Affuitenhal 1 (Unit 1.03), Zaandam [image: site icon] www.brthmrk.nl

[image: brthmrk logo]

Op vr 16 aug 2024 om 15:51 schreef Thomas Geiger @.***>:

The code samples earlier were from version v1.17 and related to the old version of the ecommerce data layer that has been already removed. Are you sure you still experience the issue? Can you reproduce the issue on https://woo.gtm4wp.dev/?

— Reply to this email directly, view it on GitHub https://github.com/duracelltomi/gtm4wp/issues/256#issuecomment-2293550855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHLKSZQEQVOAZ5MDV3PDKGDZRX7UZAVCNFSM6AAAAABMEHBZWSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGU2TAOBVGU . You are receiving this because you commented.Message ID: @.***>