fixes javascript error with tracking element id

I learned today that it's not possible to use a changing variable from
(i.e an incrementing count in a for each) in a callback (anonymous
function) because Javascript doesn't create a /new/ variable, so when
the callback is called it uses the variable in the global scope, so i
will always return the final key.