WooFunnels Documentation
Get unstuck with our helpful reference material

How to Pre-fill an Optin Form with UTM Parameters?

You can use shortcodes in your Optin fields to push data from the UTM parameter.

In this documentation, you’ll learn how to pre-fill an Optin form with UTM parameters.

Step 1: Add the snippet code on WordPress

Go to Snippets from the WordPress menu and click on Add New.

Add the snippet code on WordPress

Add the following code:

add_action( 'wp_footer', 'wffn_set_custom_cookies' );

function wffn_set_custom_cookies() { ?>
	<script>
        window.addEventListener('load', function () {
            (function ($) {
                var hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                for (var i = 0; i < hashes.length; i++) {
                    hash = hashes[i].split('=');
                   Cookies.set('bwf_'+hash[0], hash[1], {'path': '/'});
                }
            })(jQuery);
        });
	</script>
	<?php
}

Click on Save changes and then Activate the snippet.

Step 2: Go to your Optin page form

Click on the Form when editing your Optin page.

Go to your Optin page form

Step 3: Enter the default value of your field

Click on the field you want to put the UTM parameter.

Enter the default value of your field

Now put the default value of this field:

[wf_get_cookie key='bwf_utmparameter']

Please note that the cookie key always start with "bwf_" prefix.

For example, if your UTM parameter is 'first_name', then we will add this shortcode:

[wf_get_cookie key='bwf_first_name']

Once done, click on the Save changes button.

Optin Page Preview

Now, if you open the URL of your website: https://siteurl.com/page-name/?first_name=Test

The values will get pushed from the UTM parameters to your Optin fields:

pre-fill an Optin form with UTM parameters

That's it! This is how you can pre-fill an Optin form with UTM parameters.

Increase your sales, starting today.

Get WooFunnels Now
chevron-down