I am looking to track the selected destination in a form using Google Tag Manager.
To achieve this, I have created a custom JavaScript variable:
function() {
var inputField = document.getElementById("country");
return inputField.value || "";
}
When testing it in preview mode, I see the correct selection but not the desired value:
For example: If I choose "USA" from the form options:
<option value="2">USA</option>
I receive back "2" instead of "USA". However, I want the value "USA" to be captured in my dataLayer.
What could I be doing wrong?
Thank you in advance! :)