Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
Add values into hidden form fields using JS

I am trying to insert a string into the form hidden field using JS and google tag manager.

This is the script/method (worked on a bunch of different forms)

(function(){

var selector1 = $('[id="label-utm_source-f7d353cc-c056-400e-a41a-2b022eaf4340_7665"]') 
$(selector1).val('{{Read UTM Medium cookie}}');

})();

</script>

or

var selector1 = $('input name="utm_original_lead_source"') 
$(selector1).val('{{Read cookie-UTM source}}');

And nothing worked. Any idea what I'm missing here ?

Thank you!

This is the form field:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A css selector is actually a string. So this cannot work:

var selector1 = $('[id="label-utm_source-f7d353cc-c056-400e-a41a-2b022eaf4340_7665"]') 
$(selector1).val('{{Read UTM Medium cookie}}');

it should be something like this:

var selector1 = '*[id="label-utm_source-f7d353cc-c056-400e-a41a-2b022eaf4340_7665"]';
$(selector1).val('{{Read UTM Medium cookie}}');

This is also wrong:

var selector1 = $('input name="utm_original_lead_source"') 
$(selector1).val('{{Read cookie-UTM source}}');

And should be like this:

var selector1 = 'input[name="utm_original_lead_source"]';
$(selector1).val('{{Read cookie-UTM source}}');
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!