Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to cart not firing for grouped products list #256

Open
lucspe opened this issue Mar 6, 2023 · 14 comments
Open

Add to cart not firing for grouped products list #256

lucspe opened this issue Mar 6, 2023 · 14 comments
Assignees

Comments

@lucspe
Copy link

lucspe commented Mar 6, 2023

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
Copy link
Owner

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
Copy link
Author

lucspe commented Mar 7, 2023

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
Copy link
Owner

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
Copy link
Author

lucspe commented Mar 9, 2023

Hi Tamas,

Thanks for replying.

In order to try and reproduce the issue I have:

  • created a test Woocommerce installation (WP 6.1.1, StoreFront latest, only plugins: Woocommerce and GTM4WP latest versions).
  • Not sure if it matters, but PHP version is 8 and web server is LiteSpeed.
  • imported demo products directly using the sample data from WooCommerce
  • created a grouped product (as the sample demo doesn't include one)
  • connected the site to a test GTM account using GTM4WP. GTM and GA4 work fine.

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
Copy link
Owner

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: 5ecb4c1

@Floyd-Schramm
Copy link

Floyd-Schramm commented May 30, 2023

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:
- compared HTML structure to GTM4WP testing site -> https://woo.gtm4wp.dev/product/grouped-sample-product
=> only difference I could find was the different quantity selectors. I already tested with the standard quantity selectors, so the HTML structure is completely the same
- compared HTML structure to original WooCommerce grouped.php file
=> identical, with small edits from my side. I already tested it with the standard grouped.php
- checked the usage of all needed WooCommerce actions and filters, as well as class names as stated here -> https://gtm4wp.com/gtm4wp-for-developers/how-to-make-your-wordpress-theme-compatible-with-enhanced-ecommerce-tracking
=> all seem so be in place
=> Tip: maybe add the file locations where the actions and filters are expended to be used.
- changed the 'single-add_to_cart_button' class to 'add_to_cart_button'
=> Add to cart event firing, but data only includes first product data of grouped product even if it was not added to cart

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
Copy link

@duracelltomi @lucspe any updates on the topic?

@duracelltomi
Copy link
Owner

@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
Copy link

Floyd-Schramm commented Jun 17, 2023

@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
Copy link

@duracelltomi this issue is still not resolved!

@duracelltomi duracelltomi reopened this Aug 28, 2023
@duracelltomi
Copy link
Owner

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

@brthmrk
Copy link

brthmrk commented Aug 7, 2024

Any solutions yet?

@duracelltomi
Copy link
Owner

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
Copy link

brthmrk commented Aug 20, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants