i work on eCommerce website and handle google analytics events,
i pushed event using JS into dataLayer array,
add_to_cart fire correctly when product added to cart but the event fire with all items which already exist from previous event at dataLayer object with new item, i need to fire only with selected item
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'add_to_cart',
'ecommerce': {
'items': [{
'item_name': item_name, // Name or ID is required.
'item_id': item_id,
'price': price,
'item_brand': item_brand,
'item_category': item_category_1,
'item_category_2': '',
'item_category_3': '',
'item_category_4': '',
'item_variant': '',
'item_list_name': 'Search List',
'item_list_id': item_list_id,
'index': 1,
'quantity': quantity
}]
}
});
question from:
https://stackoverflow.com/questions/65915839/google-analytics-4-debug-view-monetization 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…