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

287
Views
Passing GCLID and MSCKLID to Gravity Form form values

I'm trying to capture the GCLID and MSCKLID values from the URL, and pass them into the appropriate GF form fields. I found a way to pull them from the url, but I'm running into the DRY thing when trying to pass them into their field values.

Code that pulls them from the URL:

function getUrlVars() {
     var vars = {};
     var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,    
     function(m,key,value) {
        vars[key] = value;
        console.log(value);
     });
     return vars;
}
var gclid = getUrlVars()["gclid"];
var mscklid = getUrlVars()["mscklid"];

Then this is the way I'm trying to pass them into the field values currently:

var selectorGCLID = "input[name='input_25']";
var selectorMSCKLID = "input[name='input_31']";
var fieldGCLID = document.querySelector(selectorGCLID);
var fieldMSCKLID = document.querySelector(selectorMSCKLID);
if(fieldGCLID) { fieldGCLID.value = gclid; }
if(fieldMSCKLID) { fieldMSCKLID.value = mscklid; }

What's a way where I can just check to see if the field selector is GCLID or MSCKLID, and then pass it to the appropriate field, instead of doing it 1x1 like this?

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

0

Can you just use the feature built into Gravity Forms to grab the URL parameter values?
If so, you can just go to the advanced tab of field 25 and click "Allow field to be populated dynamically" and then add: gclid. Go to field 31 and add: mscklid

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!