I just finish install magento2.3.5-p2 with sample data,

I want to understand how to collect variant data of product being added to cart at minicart

The reason for this is to be able for me to push this data into Google Tag Manager event

Screenshot attached below on the part that I require to capture from.

I wanted to get only the configureable product variant selected which is "Size :S" and "Color: Blue"

I tried tracing the code and able to see that the minicart code are processed at here


But I am unable to understand how this code works and what is the code to write to get the configureable product variant selected data

Any help is kindly appreciated

enter image description here

  • I am able to find the placement of the cart page at here 'vendor/magento/module-checkout/view/frontend/web/template/minicart/item/default.html' Mar 17, 2022 at 4:12
  • since the page use knockout js I am not able to understand much Mar 17, 2022 at 4:12

1 Answer 1


Finally able to find ways to obtain the data of the product event by using this code

selectedItem = _.find(customerData.get('cart')().items, function (item) {
    return itemId === Number(item['item_id']);

var production_options = selectedItem['options'];

or alternatively using

var productData = this._getProductById(Number(elem.data('cart-item')));

var options_for_configureable_product = productData['options'];

at page


can try put inside function _updateItemQty to test to see that it get triggered during user update item quantity

The options attribute comes from here


inside the function doGetItemData

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.