react-ga4
react-ga4 copied to clipboard
Predefined Ecommerce Event Tracking
Hi,
I wonder how to use this package to track predefined events for ecommerce.
so based on Google Documentation, the datalayer object that being sent to GTM should follow the format as below:
datalayer.push({
'event': 'view_item_list' // predefined event for ecommerce,
'ecommerce': {
'items': [_array_of_items_]
}
});
also whenever we push new ecommerce object to the datalayer, we must first clear up the previous object, with the following code:
dataLayer.push({ ecommerce: null });
any idea how to achieve this using React-ga4 package?