Recommand · October 14, 2021 0

Why does Google Enhanced Ecommerce add to cart works as a click?

In my Nuxt.js project on add to cart button there is a function which is supposed to add product in cart. Before logic of adding to cart I added code for GA Ecommerce. And when I click the button, on Google Analytics page I can see that this product is added to Product List Click section, but not in Products Adds to Cart.

There is this code:

addToCart() {
  this.$ga.ecommerce.addProduct({
    'id': this.itemProduct.id,
    'name': this.itemProduct.text
  });
  this.$ga.ecommerce.setAction('add', {
    'list': this.itemProduct.text.split(' ')[0],
  });
...
}

BUT, at the same time I have literally the same function, which also adds product to cart, and it works:

addToCart() {
  this.$ga.ecommerce.addProduct({
    'id': this.productCard.id,
    'name': this.productCard.text,
  });
  this.$ga.ecommerce.setAction('add', {
    'list': this.productCard.text.split(' ')[0]
  });
...
}

And I have no idea, why this happens that way. What do I do wrong?