Capturing Hidden Fields As A Variable Using Tag Manager

  • 31 October 2017
  • 0 replies
  • 1 view

Hi,

First post so please go easy on me!

I am trying to capture a value to use as a label in tag manager.

I’ve set a hidden field, however, using the below Javascript (Which also serves getting the Id on forms that use a drop down) I am unable to capture this.

Does anyone have any advice on the best way to do this in GTM?

function() {
var form = {{Form Element}};
var selectList = form.querySelector(’#location’);
var hiddenField = form.querySelector(’#hiddenFieldID’);

if (selectList !== null) {
return selectList.options[selectList.selectedIndex].value;
} else if (hiddenField !== null) {
return hiddenField.value;
}
return;
}

Any help is much appreciated. Sorry, I am not too familiar with Unbounce so I expect I am missing something here.

Thanks


0 replies

Be the first to reply!

Reply