Add URL params to hidden field
-
Hello, I need to pass the Google Ads GCLID, which is stored in a cookie, through a hidden field in a form. I have tried to do it with JQuery but for some reason the value is not assigned to the field. Please can you help me with this matter? This is the JQuery I’m using:
var $j = jQuery.noConflict();
$j(document).ready(function() {
// Read cookie
function getCookie(name) {
var match = document.cookie.match(new RegExp(‘(^| )’ + name + ‘=([^;]+)’));
return match ? match[2] : null;
}// Get gclid
var gclidValue = getCookie(‘gclid’);// Assign the cookie value to the hidden field with class ‘mf_hidden_gclid_class’
$j(‘.mf_hidden_gclid_class’).val(gclidValue).trigger(‘change’);
});Thank you!!
- The topic ‘Add URL params to hidden field’ is closed to new replies.