How to Use Cookies to Capture URL Parameters

In:

A couple months ago I wrote a tutorial on how to use UTM parameters to capture lead source. The tutorial is an in-depth overview of how to capture URL parameters when a lead visits a landing page directly but if a lead visits a different page then fills out the form, those URL parameters won’t be captured. To fix this issue, you can store cookies in the lead’s browser and configure the form fields to pull from the cookie values instead of the URL parameter.

hidden-fields-in-forms-2

In this example, we will be setting 3 different cookies.

  1. utm_source
  2. utm_medium
  3. utm_campaign

Parse the URL

The URL parameters need to be parsed so the cookie values can be set. This can be done using javascript.

Setting the Cookie Values

In order to set the cookie values, jQuery and the jQuery Cookie Plugin must be on the page.

The syntax for creating a cookie using the jQuery plugin is very simple.

Using the variables defined in the first step, the cookie values can be set.

Testing

To ensure the cookie values are being stored in the browser correctly, open up Chrome -> Developer Tools and click on the Resources tab.

utm-cookies

The cookies utm_source, utm_medium and utm_campaign should be visible in the console.

Setting the Form Field Values

Now that all the UTM parameters are being stored in the lead’s browser, the forms need to be configured to grab the cookie value.

Putting it All Together

The Code on your page should look similar to this.

Questions?

Email me, or send me a tweet @jennamolby.

Related Posts

  • 13/04/2017
    How to Use Salesforce Campaigns in Pardot to Track Campaign Influence

    Identifying which campaigns and channels have influenced an opportunity is a key piece of information to see which marketing campaigns are the most effective. In this tutorial, I’ll walk you through how I use Salesforce campaigns in Pardot to track campaign influence.






  • 17/10/2016
    9 Things You Should Know About The Marketo Account Based Marketing Platform

    Earlier this year at Summit, Marketo announced that they would be launching an Account Based Marketing Platform. As of September 2016, Marketo has officially launched their Account Based Marketing Platform as part of their Summer ’16 launch. There’s been a lot of buzz about Marketo ABM and its benefits, so I thought I would break everything down into the top 9 things you should know about the Marketo Account Based Marketing Platform.






  • 19/05/2016
    How to Use a Pardot Form to Gate Content on a Page

    In this tutorial you will learn how to use a Pardot form to gate content on a page. Gated content allows you to capture a lead’s information, by asking them to provide contact details before accessing a piece of content that is valuable. Instead of creating more than one page for the gated content and form, this tutorial will focus on creating a popup on the page that contains the asset.






2 comment(s)
  • Jessie

    24/02/2017 at 9:04 am
    Reply

    You are a lifesaver! Thank you!!

  • […] to get value from cookie value, but it doesn’t store the cookie for you. You will need some javascript code embeded on your website to store the […]

Leave A Comment

Your email address will not be published. Required fields are marked *

About Me

I’m a Marketo & Pardot expert with a strong background in design and development. I specialize in email marketing, lead nurturing and CRM integrations for marketing and sales alignment. LEARN MORE

Categories
Most Commented
Popular Posts