Mateusz Dąbrowski Mateusz Dąbrowski

Eloqua marketing automation specialist, e‑mail geek and python enthusiast.

Capture tracking parameters

In the age of digital analytics, everyone uses tracked links. Let's explore how can we use them to support our marketing automation activities.

Article outline

  1. Query strings and why you should have them in form submissions
  2. How to capture tracking parameters with form?
  3. Improve your marketing automation with query string capturing
  4. Use the Eloqua built-in query string functions


Power of query strings

Query strings are everywhere. Search 'value' on Google, and you will see ?q=value in the address bar. Open an image on Facebook timeline, and the link will have ?type=3&theater at the end. Click any link in the promotional mail you receive, and you will find similar elements too. But what they are and how can we use them?

Query string is the part of a uniform resource locator (URL) containing data that does not fit conveniently into a hierarchical path structure.

Despite being a bit vague, this definition tells us a fundamental idea. Query strings are a tool to transfer data using a link as a medium. Google Analytics users are familiar with UTM parameters (utm_source, utm_medium, utm_campaign, utm_content, utm_term). Digital marketers use them to identify sources and campaigns that brought users to their communication. Or, in other words, they use links to send additional data about traffic to Google Analytics. Many also add own queries to fulfil their reporting needs. For example, writing down dimensions of an ad will help you find which creation got the best conversion rates and should be used more in the future.

Why would want such data in our marketing automation tool? Capturing UTM parameters within form submissions allows you to learn what are the primary sources of traffic quickly. That is very handy for both checking if all promotional sources are live and applying more focus to the ones with the best conversion rates to get even more from your campaign. It's faster than Google Analytics and allows you for easy per‑user attribution. Another reason is the ability to utilise query strings to personalise the message. For example, you may link content articles focusing on various legal problems (civil, corporate and data protection law) to a landing page with a whitepaper download form. By capturing UTM parameters, you can personalise e‑mail communication with messaging related to the legal problem mentioned in the source article for each user.


How to capture a query string

We already know that capturing query strings will give you more data for actionable insights and an opportunity to increase engagement with highly personalised communication. Time to show how you can do it.

1. Dedicated fields in the form

Form creator in Eloqua Marketing Automation tool
Example of form fields configuration in Eloqua Marketing Automation tool

To catch tracking parameters, you will need two things. The first - unique fields to store captured information. In the above image, you can see form template with four fields for chosen UTM tags and one field for base URL (the latter being useful if you place one form on multiple landing pages). The number of fields should be equal to the number of query elements you want to catch and store.

The most important part here is to write down unique HTML names you choose for those form fields, as they will be necessary for the second part. Best practice is to make those fields hidden from customers sight. It can be done either within the marketing automation form creator or with simple CSS rules.

2. JavaScript in the landing page code

Sample JavaScript capturing four UTM parameters and base URL

Despite the messy look, the script is easy to use. It consists of two functions. First, named getQueryStringParamValue is responsible for splitting the URL into single elements that we can capture. I already configured it so you won't need to change anything there It is the second function, setCampaignInfo, that will be into the spotlight. Within its body, we will configure what URL elements we want to catch and where to put them within the form. As you can see, there are two different lines used.

document.forms[#].html_field_name.value = getQueryStringParamValue('parameter');

The first one captures query strings and to configure it we need to fill in three variables (marked with red colour above). # should be a number telling the script which forms on your landing page you want to target. In most cases, you will write 0 there (to focus the first/only form). However, if you were to have multiple forms on one page, you can increment that number to target all of them. The second variable you will need to fill is html_field_name. In this spot, you should insert HTML name of the form field where you want to store a particular tracking parameter (as mentioned in 1. Dedicated fields in the form). Last variable, parameter, should be equal to the query name you want to catch. For example, if the query is ?utm_medium=email, you should end up with ('utm_medium') at the end of the line.

document.forms[#].html_field_name.value = window.location.href.split(/[?#]/)[0];

The second line of code catches base URL. Again there is # and html_field_name to fill, just as explained above, but you don't need to write parameter variable, as that line is already prebuilt to catch base of the link.


Unleash the full potential of URL

I already mentioned how useful capturing query strings might be in the first part of this article. However, there is more. Now that you know how to implement this solution, it is time to abuse its possibilities.

Have you ever thought that it would be great to have Facebook's or LinkedIn's knowledge about their users? Or maybe would love to have more data on your customers, but you are afraid that too long form will deter them from submission? Let's think about how query capturing can help us.

For example, you want to launch a Facebook ad campaign promoting a whitepaper and targeted to people interested in law. Now you can get more from it. Create multiple campaigns (with the same or different creations) focused on more specific groups (different by gender, age, location). To the link leading to a whitepaper form append your query string with different fill for every group: ?gender=male​&age=18‑24​&location=London. With query string capturing you can catch all that information and nurture your database.

Are you planning to put your ads on various third‑party websites with different reader personas? Catch that data and nurture your database. Business partners offered that they can send your e‑mail to their contacts? Query your links, nurture the database. Have campaign of QR codes in various locations? You know the drill.

Simplified drag and drop solution

What is even more interesting is the fact that you don't have to code even one line to start leveraging the opportunities mentioned above. Oracle's Eloqua offers simplified version as a built-in feature. To use it all you need to do, is to configure two elements.

1. Website Setup » Query Strings

Firstly, within the Assets tab there is a Website Setup menu, where - among other great features, you can find an option called "Query Strings". It allows you to add new query string parameters that will be tracked by Eloqua. Basic configuration takes a second - write selected query string parameter within both Display Name and Parameter fields (for example "utm_campaign") and leave rest of the settings as default. Save, repeat for all parameters queries you want to catch, and done!

2. Field Merge » Query Strings

Now it is time to make use of what you just created. Go to Field Merge library, create new and change Merge From setting from default Contact Field to Query String. Add query string parameter name you want to field merge (one of those you wrote in the previous step) and - you guessed it. Repeat for all parameters, and done!

Now you have nicely working field merges that capture query strings from URL. Put it within an Eloqua Form field just as described above and get the most of it. What are limitations of this approach versus javascript path? It works only in Eloqua Forms that are on Eloqua Landing Pages and whenever you want to capture new query string parameter you have to create both mentioned elements. If you are ok with that, great, use it and abuse it.

Relevant articles