Skip to content

view_cart Event Triggered on Every Page with Hyvä Theme and Ajax Add To Cart #281

@Ylmzef

Description

@Ylmzef

The view_cart event is being triggered on every page, not just the cart page or when the minicart is collapsed.

To Reproduce
Steps to reproduce the behavior:

  1. Install Yireo_GoogleTagManager2 on a Magento 2 store using the Hyvä Theme.
  2. Use the Ajax Add To Cart UI Component to add products to the cart.
  3. Observe the view_cart event in the browser’s GTM preview/debug mode.

Expected behavior
The view_cart event should only fire when the cart is actually viewed, not on every page.

Actual behavior
The view_cart event fires on all pages, regardless of whether the cart is viewed or not.

Environment

  • Magento 2 version: 2.4.8-p2
  • Yireo_GoogleTagManager2 version: 3.10.0
  • Theme: Hyvä
  • Other relevant modules: Ajax Add To Cart UI Component

Suggested solution (if any)
Consider restricting the view_cart event to only trigger on actual cart page views or when a user opens the mini-cart, rather than listening globally for cart updates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions