Storing URL Tracking Parameters
In the event you'd like to store URL tracking parameters (e.g. utm_source
, utm_medium
, etc) in your form submissions, this can easily be done. Just follow the steps below:
Instructions
-
Open up an existing form in Freeform. For the purpose of this example, let's assume it's called
Contact
. -
Create and add 3 new Hidden fields to your form layout with the handles of:
utm_campaign
utm_source
utm_medium
The field names/handles do not have to match the query parameter names, but we've done it that way for this example.
-
In the regular template where you are loading the form, you'll need to add the values parameter and grab the values from the URL with
craft.app.request.getQueryParam('')
:{% set form = craft.freeform.form("contact", {
overrideValues: {
utm_campaign: craft.app.request.getQueryParam('utm_campaign'),
utm_source: craft.app.request.getQueryParam('utm_source'),
utm_medium: craft.app.request.getQueryParam('utm_medium')
}
}) %} -
Assuming your URL looks something like the following, Freeform will then grab those values and plug them into the corresponding hidden fields:
https://mysite.net/contact?utm_campaign=my_campaign&utm_source=google_jobs_apply&utm_medium=organic