# GA4: view\_item with variable products

**URL:** <https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062>\
**Category:** Mergado Pack WooCommerce\
**Created:** [September 4, 2024, 3:59pm UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062 "2024-09-04T15:59:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![honza.kopecky95](https://forum.mergado.com/user_avatar/forum.mergado.com/honza.kopecky95/32/1250_2.png) [@honza.kopecky95](https://forum.mergado.com/u/honza.kopecky95)\
**Post date:** [September 4, 2024, 3:59pm UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/1 "2024-09-04T15:59:36Z")

</div>

Hello there,

since we managed to resolve issues with more important events, our web analysts now noticed another problem - this time with the `view_item` event.

On our website, we are using a lot of variable products. Unfortunately, the data sent with the `view_item` event are incorrect and there are multiple situations were the problem appears:

1. When using a parametrized URL such as: [https://www.jagaia.cz/produkt/breathein/?attribute\_pa\_obsah=33ml](https://www.jagaia.cz/produkt/breathein/?attribute_pa_obsah=33ml), you can see that the item ID send in the event is correct - it is in the format of `productId-variantId` where both IDs are correct, but the rest of the item’s data are incorrect. I checked the source code in `mergado-marketing-pack/src/Service/External/Google/GoogleAnalytics/GA4/Ga4ServiceIntegration.php` and it is quite clear that the variant only influences the item id and nothing else - for example the prices or categories are obtained for the “parent” product, not the correct variant. I believe this is incorrect behaviour. I am also unsure why is there the need for this `productId-variantId` format. To me it would seem more reasonable to just have the variantId here same as you do with `add_to_cart` or `purchase` events.
2. When not using the parametrized URL, the source code just doesn’t take variants into account at all. I understand that one could think that in that scenario you don’t have information about the displayed variant (or that there is no variant displayed) but that’s true only sometimes. Woocommerce supports [default variations](https://woocommerce.com/document/variable-product/#setting-defaults) which we use on our website, so if there is not a parameter in the URL, the wbsite will display the default one. I believe this would be true not just for our website and I believe the tracking should respect this WooCommerce settings.

I believe the fix for both of these problems should be quite easy - just fetch the product by the variation id before obtaining any information for the event. Btw just be careful not to override the global `$product` variable as it could break many things.

Looking forward to your reply!  
Honza

---

<div class="post-metadata">

**Author:** ![robin.fuksa](https://forum.mergado.com/user_avatar/forum.mergado.com/robin.fuksa/32/1312_2.png) [@robin.fuksa](https://forum.mergado.com/u/robin.fuksa)\
**Post date:** [September 6, 2024, 9:30am UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/2 "2024-09-06T09:30:04Z")

</div>

Hello,

Thank you for reaching out to our support team. Parameterized URLs will be implemented in the next version of the Mergado PACK plugin. Regarding the IDs, we will need to discuss this issue further with our developers.

We will inform you of the outcome soon.

Best regards  
Mergado Pack support team

---

<div class="post-metadata">

**Author:** ![robin.fuksa](https://forum.mergado.com/user_avatar/forum.mergado.com/robin.fuksa/32/1312_2.png) [@robin.fuksa](https://forum.mergado.com/u/robin.fuksa)\
**Post date:** [September 27, 2024, 12:23pm UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/3 "2024-09-27T12:23:15Z")

</div>

Hello,

After weighing all the pros and cons, we will add an option to configure which ID should be sent - either `productId` or `variantId`, if it exists. This will be implemented in the next major version release of the Mergado PACK plugin

Best regards  
Mergado Pack support team

---

<div class="post-metadata">

**Author:** ![honza.kopecky95](https://forum.mergado.com/user_avatar/forum.mergado.com/honza.kopecky95/32/1250_2.png) [@honza.kopecky95](https://forum.mergado.com/u/honza.kopecky95)\
**Post date:** [October 1, 2024, 12:06pm UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/4 "2024-10-01T12:06:16Z")

</div>

Hey there!

Thanks for letting me know. Looking forward to that! Is there any ETA on that update?

Honza

---

<div class="post-metadata">

**Author:** ![robin.fuksa](https://forum.mergado.com/user_avatar/forum.mergado.com/robin.fuksa/32/1312_2.png) [@robin.fuksa](https://forum.mergado.com/u/robin.fuksa)\
**Post date:** [October 1, 2024, 12:22pm UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/5 "2024-10-01T12:22:11Z")

</div>

Hello Honza,

ETA is approximately 30 days. ⏱ In other words, we aim to release the new version of the pack by the end of October.

The time requirement is primarily driven by the significant number of new features, fixes, and updates. Additionally, ensuring compatibility with the latest versions of WordPress and WooCommerce is a key factor.

Best regards  
Mergado Pack support team

---

<div class="post-metadata">

**Author:** ![honza.kopecky95](https://forum.mergado.com/user_avatar/forum.mergado.com/honza.kopecky95/32/1250_2.png) [@honza.kopecky95](https://forum.mergado.com/u/honza.kopecky95)\
**Post date:** [October 1, 2024, 12:36pm UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/6 "2024-10-01T12:36:36Z")

</div>

Thanks, that sounds fine to me!

Honza

---

<div class="post-metadata">

**Author:** ![robin.fuksa](https://forum.mergado.com/user_avatar/forum.mergado.com/robin.fuksa/32/1312_2.png) [@robin.fuksa](https://forum.mergado.com/u/robin.fuksa)\
**Post date:** [November 13, 2024, 9:24am UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/7 "2024-11-13T09:24:33Z")

</div>

Hello Honza,

I’m reaching out to you after a while, hopefully with good news. We have just released a new major version of the Mergado Pack plugin with improvements addressing this issue.

Check out all the details in the article below!

> [@\[RELEASE\] Mergado Pack v4.0.1 for WooCommerce](https://forum.mergado.com/t/release-mergado-pack-v4-0-1-for-woocommerce/1084):
>
> Version of plugin: 4.0.1 Release date: 11/11/2024 Requires: WooCommerce Minimal PHP: 7.1+ We are excited to announce the release of a new major version of the Mergado Pack plugin! This version brings a host of new features, fixes, and improvements. tadawarning The main change involves the configuration of advertising systems—Google (GAds, GUA, GTM), Facebook, Glami, and Biano pixel. There has been an update in the VAT processing within the product price settings. All events now follow …

If you encounter any issues or unexpected functionality, please don’t hesitate to let us know.

Best regards  
Mergado Pack support team

---

<div class="post-metadata">

**Author:** ![honza.kopecky95](https://forum.mergado.com/user_avatar/forum.mergado.com/honza.kopecky95/32/1250_2.png) [@honza.kopecky95](https://forum.mergado.com/u/honza.kopecky95)\
**Post date:** [November 13, 2024, 10:31am UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/8 "2024-11-13T10:31:54Z")

</div>

Hello Robin,

thanks for the update. I just installed it and carried out some simple tests and I can confirm that the parametrized URLs and (non)composite IDs work great. In our case, the view\_item and select\_content events now work great.

There is although one little drawback. Without a parametrized URL, the `view_item` event still sends the ID of the product (which actually never gets added to cart since it’s a variable product) instead of the ID of the default variant of the product which is actually displayed to the user.

Let’s take the example of our BREATHE IN product ([https://jagaia.cz/produkt/breathein/](https://jagaia.cz/produkt/breathein/)). The iD of product is 13089. The variants have teh following IDs:

- 1,5ml: 13090 [Breathe in – JAGAIA](https://jagaia.cz/produkt/breathein/?attribute_pa_obsah=vzorek-15-ml)
- 15ml: 13092 [Breathe in – JAGAIA](https://jagaia.cz/produkt/breathein/?attribute_pa_obsah=15ml)
- 33ml: 13091 [Breathe in – JAGAIA](https://jagaia.cz/produkt/breathein/?attribute_pa_obsah=33ml)

When you use the parametrized URLs, view\_item is tracked correctly. But when you use the one without the parameter ([https://jagaia.cz/produkt/breathein/](https://jagaia.cz/produkt/breathein/)), the ID 13089 is sent even though the (WooCoommerce configured) default variant (15ml, ID 13092) is displayed to the user.

Is this anything we could resolve?  
Thanks in advance.  
Honza

---

<div class="post-metadata">

**Author:** ![robin.fuksa](https://forum.mergado.com/user_avatar/forum.mergado.com/robin.fuksa/32/1312_2.png) [@robin.fuksa](https://forum.mergado.com/u/robin.fuksa)\
**Post date:** [November 18, 2024, 11:15am UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/9 "2024-11-18T11:15:04Z")

</div>

Hi Honza,

Apologies for the delayed response and thank you for your fast feedback! ✍

I have already forwarded your information to the plugin developer. In the new version, we are implementing the adjustment (see the changelog) along with some minor bug fixes.

I have sent you the updated version of the plugin in advance so that you can conveniently test the proper functionality in your environment.

Once everything is ready and thoroughly tested, we will release the new version of the plugin for public download.

**Changelog** :

- If you navigate to a product detail page and the URL is not parameterized, it checks whether a default product is available, and if it exists, it uses it.

Best regards,  
Mergado Pack Support Team

---

<div class="post-metadata">

**Author:** ![honza.kopecky95](https://forum.mergado.com/user_avatar/forum.mergado.com/honza.kopecky95/32/1250_2.png) [@honza.kopecky95](https://forum.mergado.com/u/honza.kopecky95)\
**Post date:** [November 18, 2024, 11:19am UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/10 "2024-11-18T11:19:43Z")

</div>

Hi Robin,

I can confirm the new version fixes the problem and it now works as expected!

Thanks for the support!  
Honza

---

<div class="post-metadata">

**Author:** ![robin.fuksa](https://forum.mergado.com/user_avatar/forum.mergado.com/robin.fuksa/32/1312_2.png) [@robin.fuksa](https://forum.mergado.com/u/robin.fuksa)\
**Post date:** [November 22, 2024, 2:41pm UTC](https://forum.mergado.com/t/ga4-view-item-with-variable-products/1062/11 "2024-11-22T14:41:07Z")

</div>

A new patch version 4.0.2 of the Mergado PACK plugin has just been released to address this issue!

> [@\[RELEASE\] Mergado Pack v4.0.1 for WooCommerce](https://forum.mergado.com/t/release-mergado-pack-v4-0-1-for-woocommerce/1084/2):
>
> Version of plugin: 4.0.2 Release date: 19/11/2024 Requires: WooCommerce Minimal PHP: 7.1+ A new patch for the Mergado PACK plugin with a few improvements and fixes related to the new version 4.0. &nbsp; IMPROVEMENTS: chart_with_upwards_trend Implemented logic to take default variation on product detail page if not accesses using parametrized url. Exception handling and logs. &nbsp; BUGFIXES: wrench GA4 – Missing cart\_data object in cart. Fixed occasional notices that could appear in rare c…
