I recently was tasked at work to automatically grab some query string parameters on page load insert as hidden field data into a form to be submitted along with other info when the user submits the form.
The query string parameter data is sent along with the user info to the CRM for offline sales conversion tracking.
const qstring = qs.get();
const gclid = qstring.gclid;
document.getElementById("gclidInput").value = gclid;
After my programming buddy looked at what I did though, considering I only needed the 'gclid' query string parameter, I could've accomplished the same with less code by just using the Location Search Property of the Location Object.
I'll probably end up doing that and when I do I'll be sure to let you know the code I wrote to achieve this.