I've tried to add an event on an 'Add to cart' button, but it is not triggering and I don't know hot to do it.
ReactGA4.gtag("event", "add_to_cart", {
currency: "RON",
value: price,
items: [
{
item_id: id,
item_name: title,
item_category: 'book',
price,
quantity: 1,
},
],
});
The initialisation is correct, other events such as pageviews work.
I expect to send that event whenever I click that button.
To solve the problem, I created my own implementation of Google Tag Manager with manual calls to Google Analytics.
I use React (18.0.9) with TypeScipt