react-ga4
react-ga4 copied to clipboard
ReactGA.plugin.require("ecommerce");
Previously with react-ga we could use this code:
ReactGA.plugin.require("ecommerce");
ReactGA.plugin.execute("ecommerce", "addItem", {
id,
name,
sku,
category,
quantity
});
ReactGA.plugin.execute("ecommerce", "addTransaction", {
id,
revenue
});
ReactGA.plugin.execute("ecommerce", "send");
Is there another way to pass data to Google Analytics Ecommerce with GA4 / react-ga4?
Using the conversion guide you should be able to use the gtag function:
import ReactGA from 'react-ga4'
// ...
ReactGA.gtag('event', 'purchase', {
transaction_id: id,
value: revenue,
items: [
{
item_id: sku,
item_name: name,
item_category: category,
quantity,
}
]
})
Is there a specific variable type we need to pass on for value?