Learn business growth with Google Analytics 4 › Forums › Google Analytics 4 › Identifying line item indexes with JavaScript › Reply To: Identifying line item indexes with JavaScript
-
Sure, no problem. The issue was with your 5th line of code, but don’t worry – it’s a pretty simple mistake to make. The part of the code where you refer to a ‘child’ of an element, you were using a static value instead of the variable index.
I’ve made the change for you here:
elements[index].children...
.This will make sure that each child gets a different index rather than the same one. Just a little hiccup that needed to be addressed. Keep at it! You’re doing great!