Hidden Fields Filled with UTM Code

Hi

I need assistance in setting up hidden fields to pull UTM information from the URL.

I have set up 3 hidden fields in my form

UTM_MEDIUM
UTM_CAMPAIGN
UTM_SOURCE

I havent amended the form url as yet either - as I am not sure how it would look with the 3 UTMs
maybe something like this - https://blahblahblah.activehosted.com/f/5?utm_source=??&utm_medium=??&utm_campagn=??

From what I understand I need a Javascript snippet? Any pointers int he right direction would be wonderful please :slight_smile:

The ultimate goal is to enable a CRM to pull the UTM information from the lead forms generated.

Any assistance appreciated.

1 Like

If you’re using WordPress for your forms you can use this handy plugin:

(You won’t be able to use Javascript on forms hosted by AC).

One point, though. Your fields will always feature the latest campaign info, and not keep a history… if a user reachers your site via multiple campaigns. There is no way to only retain the first set of data populating the fields either.

An alternative, and you’ll have to Google the instructions for this, is to have the UTM values captured as events.

1 Like

Hi,

You just need to put the form (either through the small piece of script or the full form html) on a page and it will automatically insert the URL parameters in the hidden fields IF you name those parameters exactly the same as your form fields like you mentioned in your example. Note that this only works if you have a landing page where leads immediately sign up, if they browse on other pages so that the URL parameters disappear you won’t have the data filled automatically anymore.

You can go around that by storing those utm parameters in a cookie and putting some javascript in place to grab the values from the cookie and put it in your hidden fields. There are a lot of good tutorials to do that, e.g. https://jennamolby.com/how-to-use-cookies-to-capture-url-parameters/

The way I finally made this work was Handl UTM grabber, but you have to follow the instructions on this page for ActiveCampaign to work.

It’s tricky though. One of the little things I missed is when it says to replace
value = “”
with
value = “%s”

FYI - WPengine Users:

WPengine deletes cookie (where utms get saved by HandL) on the server side.

You need to contact support and tell them:

"Hi! I’m looking to cache exclude some cookies from my site. Here is the list:

utm_
gclid
fbclid
handl_
email
username

thanks!"