Skip to content

Instantly share code, notes, and snippets.

@chriswagoner
Created January 14, 2022 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriswagoner/34ddb40bbb93269bb0121de08058ad96 to your computer and use it in GitHub Desktop.
Save chriswagoner/34ddb40bbb93269bb0121de08058ad96 to your computer and use it in GitHub Desktop.
Get Query Parameter and throw it into a form field
// Here we are targeting a Hubspot form, grabbing the GCLID (from a Google ad click) and popping it into the hidden Hubspot field value that has the ID of GCLID.
jQuery(".hs-form").submit(function() {
ga(function() {
if (jQuery('#gclid').length) {
jQuery("#gclid").val(ga.getAll()[0].get('_gclid'));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment