I am trying to call the below through in Google Tag Manager:
document.getElementById('Travel_J608883332').innerText
An issue I have is that the ID changes with each booking i.e. the J608883332
is dynamic to the booking number.
I have read about using the querySelectorAll method to create a Regex pattern that might pull back the element dynamically:
return document.querySelectorAll('span[id="^TravelBy\_J.*"]').innertext
However the above is returning "undefined" when I test in Google Tag Manager. I assume I have made an error in constructing it?
Apologies for the naive question, I am new to this method.
Thanks, M