How do I set the hidden Leadsource field based on URL param in Infusionsoft form?

We want to host the IS form on our site. We also want to use the same form for multiple channels like PPC, FB etc. The links to our pages will include the source (for example we could use utm_source =FBAd).
I want to extract the lead source value from the URL param and set the Leadsource value when the user submits the form. So I tried creating a form with the Leadsource as a hidden field. However, when I use the HMTL code (unformatted), I see the hidden field but it does not have the id associated with the Leadsource field. Other fields like name and email have the id so I can set the value by using the Java script code document.getElementById(‘inf_field_FieldName’).value = getUrlParameter(‘utm_source’);

I am not a Java script expert so I am assuming there is another way to accomplish this. Hopefully, I am not the only one attempting to do something like this.

Email *

So we’re talking about the webform widget and not the landing page widget?

You can take the leadsource tracking code in your ecommerce setup and place it into the webform in a script tag.

Hi John,

Thanks for your response.
That’s right we are talking about the webform widget.
What if I want to set the Leadsource value based on a specific url param whose value is set to a Leadsource we have created in IS? For example, we have paid search (id=1021) and I want that id to be passed in the URL param so we attribute the form submission to that specific channel. Would that still work if I do what you suggested.

Thanks

Devaraj

To do that would take some coding. It would require grabbing the code from the url, passing it along to a middle ware script that would then update with the correct leadsource and then forwarding to a thank you page. The user doesn’t notice any of this but it’s a common process for updating information that isn’t inherently available out of the box, which, selective leadsource through the url is not :wink:

Yep. Got it. I was able to make it work. I had to tweak the Java script a little bit. Thanks for your help.

1 Like

I use a third-party tool that helps us track the traffic source for all lead and ecommerce transactions using Keap optin forms hosted on our site or order forms. More info here - Infusionsoft Google Analytics Ecommerce Tracking - Start Smart Now.

The challenge is that Infusionsoft’s lead source field isn’t a standard form field that you can easily populate with JavaScript like you would with name or email fields. It’s more of a system field that gets set through Infusionsoft’s internal processes.

You have a couple of options here:

The simplest approach is to create a custom field in Infusionsoft (like “Marketing Source” or “Campaign Source”) and use that instead of the built-in lead source field. Custom fields behave like normal form fields, so your JavaScript approach of pulling the UTM parameter and setting the field value should work perfectly.

Alternatively, there are tools like Attributer that can handle this automatically for you (disclosure: I am the founder). It captures UTM parameters when visitors first land on your site, stores them in a cookie, and then writes them into hidden fields on your Infusionsoft forms when they’re submitted. So someone could click your Facebook ad, browse around your site, and when they eventually submit the form it would still capture “FBAd” from the original utm_source parameter.

As a bonus, it also captures data on leads that come from organic channels (like Organic Search, Organic Social, Direct Traffic, etc.) where you don’t have UTM parameters, plus things like the GCLID for Google Ads conversion tracking.

Yeah, Infusionsoft’s hosted forms don’t generate standard HTML IDs for their lead source field like they do for other fields, which makes it tricky to populate via JavaScript.

You have a few options here:

The easiest approach is to use tools like Attributer that handle this automatically. It captures the UTM parameters (plus other attribution data like organic search, direct traffic, etc.) when someone first lands on your site, stores them in a cookie, and then writes them into the lead source field when they submit your Infusionsoft form. So someone could click your Facebook ad, browse around your site, and when they eventually convert the lead source would still be captured as “Paid Social” with the campaign details.

You could also try to write custom JavaScript to find the lead source field by its name attribute rather than ID, but Infusionsoft’s form structure can be inconsistent and this approach often breaks when they update their form rendering.

The other benefit of using a dedicated tool is that it categorizes your traffic properly. So your Facebook ads would show up as “Paid Social” rather than just “FBAd”, and you’d also capture leads from organic channels that don’t have UTM parameters (like people who Google your company name and convert).

You could certainly try to bridge this with custom code, but maintaining that script as Infusionsoft updates their forms and as browsers change behavior can be quite time-consuming.