Learn business growth with Google Analytics 4 Forums Google Analytics 4 Trouble activating add_to_cart event with GA4 and React-ga4

  • Trouble activating add_to_cart event with GA4 and React-ga4

    Posted by Taylor on 31 January 2023 at 10:02 pm

    Hey, so I’m trying to set up an event for when someone clicks the ‘Add to Cart’ button on my site, but for some reason, it’s just not triggering. Here’s the code I’m working with:

    ReactGA4.gtag("event", "add_to_cart", {
          currency: "RON",
          value: price,
          items: [
            {
              item_id: id,
              item_name: title,
              item_category: 'book',
              price,
              quantity: 1,
            },
          ],
        });
    

    I made sure to initialize everything correctly, and other events like pageviews seem to be working fine. My goal is to have this event fire each time the button is clicked. Can you help?

    Taylor replied 1 year, 5 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

Log in to reply.