A newer version of

Freeform

is available.

Try Freeform 5 now →

User Guides

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

    TIP

    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 overrideValues 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')
        }
    }) %}
    
    1
    2
    3
    4
    5
    6
    7
  • Assuming your URL looks something like the following, Freeform will then grab those values and plug them into the cooresponding hidden fields:
    • https://mysite.net/contact?utm_campaign=my_campaign&utm_source=google_jobs_apply&utm_medium=organic
Finished!
User Guide:

Check out our other guide for passing along other types of data to Freeform form fields.