- Issue created by @kepesv
- πΊπΈUnited States g.paluch
It's likely not a module issue. If you can confirm that your dataLayer sends data in the console, it is likely a GA threshold, meaning your site doesn't produce enough data for GA. You can change this in GA in Settings>Data Collection and Modification>Data Collection by disabling
"Include Google signals in reporting identity."
- Status changed to Needs review
almost 2 years ago 3:47am 28 November 2023 - ππΊHungary kepesv
Many thanks for Your response.
Google signals data collection wasn't activated yet (so there was no "Include Google signals in reporting identity" switch).
Now I've turned on Google signals data collection. I'll check it a few days later. - Status changed to Active
almost 2 years ago 3:21pm 21 December 2023 - π¨πSwitzerland berdir Switzerland
Add payment info and shipping are currently empty placeholders that are not implemented, so it's not surprising that nothing shows up there.
I'll likely have a look at that soon as we probably need this too.
- Assigned to durifal
- πΈπ°Slovakia durifal
I am working on the patch to support data for payment and shipping info.
- Issue was unassigned.
- πΈπ°Slovakia durifal
I have just found out that the checkout process on the project is too custom to create universal patch :-(
- πΊπΈUnited States rszrama
(I'm marking this and another issue with a "Deprecate Commerce GTM" tag. These are issues that fill gaps for us to formally recommend closing that module and migrating sites to this one.)
- πΊπ¦Ukraine khiminrm
I've found two solutions how we can fix it. Iv'e tested only 'add_to_cart' event yet. But I think it should work other events too.
So first solution is to use GTM tags by using these steps:
GA4 Event Tag Setup:
Ensure the GA4 Event tag in GTM for add_to_cart is correctly configured. This includes selecting "Google Analytics: GA4 Event" as the tag type, entering the correct GA4 Measurement ID, and setting the Event Name to add_to_cart.
Ecommerce Data Source:
Verify that "Send Ecommerce data" is checked within the tag settings and "Data Layer" is selected as the Data source under "More settings β Ecommerce."
Trigger Configuration:
Confirm the trigger associated with the add_to_cart tag is correctly set up as a "Custom Event" with the Event Name matching add_to_cart.So in my test GTM I have added such tags:
First one is config tag for GA4, where I've used ID from my GA:
And another one is for the 'add_to_cart' event (it also uses the same GA ID):
With such configuration I was able to see the 'add_to_cart' event in Google Tag Manager Preview Mode and in DebugView in GA4.
But there were two sent events and one of them had 'send_to' parameter with GA ID and another one didn't have those param:
And in the first event we have value under 'Hits Sent'.
Then I've tried to pause the 'add_to_cart' event tag in my GTM's tags settings and the param with hardcoded GA ID directly into the code of the
AddToCartEvent::getDat():return [ 'currency' => $unit_price->getCurrencyCode(), 'value' => $this->formatPriceNumber($adjusted_price), 'items' => [ $item_data, ], 'send_to' => 'G-MYGA4ID', ];With this fix I had only one add_to_cart event and it was visible in DebugView in GA4. I hope it will be displayed on Purchase Journey page too. Will need to wait when the data will be updated there.
I've also noticed caching issue when tested the event. So maybe it's related to https://www.drupal.org/project/google_tag/issues/3281487 π¬ GTM not firing when page is cached Active
So I've just disabled caching in my settings.local.php file:<?php ///** // * Enable local development services. // */ $settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml'; $settings['cache']['bins']['render'] = 'cache.backend.null'; $settings['cache']['bins']['page'] = 'cache.backend.null'; $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';For the second solution with the 'send_to' param we need to improve code of the google_tag module to be able to add GA ID and use it in return data for each event. Not sure or we need one global setting field for GA ID and checkbox for an events to include those 'send_to' param or it would be better to add the field per each event and use it when it's needed?
- πΊπ¦Ukraine khiminrm
Committed code to send data for the add_payment_info. Not sure if it's correct to use the payment insert event. Maybe we should try to trigger the event on the payment information checkout step submission. And maybe similar should be for the add_shipping_info event...