Eloqua Blog · Advanced
Passing GA Data Through Eloqua Forms
Part three of my Google Analytics and Eloqua series. In this part I show you how to detect UTM parameters on your landing pages and pass them directly into Eloqua forms without your users ever seeing them.
📅 First published: 17 May 2019 · Updated and rewritten
⏱ Complexity: Intermediate • 👥 Audience: Web Teams, Marketing Ops, Eloqua Admins • 🎯 Focus: GA to Eloqua form capture
Part 3: Detecting UTM parameters on landing pages and passing them to Eloqua
At this stage of the series you have already created a clean UTM framework and set up Eloqua to automatically tag every email link with GA friendly tracking. Now you need a way to capture those UTM values at the point where it matters: the form submission.
If you missed the earlier parts, start here: Part 1 and Part 2 of the series .
In this part you will learn how to detect UTM values on your landing pages, store them in hidden fields and pass them directly into Eloqua.
Where we are in the 4 part series
- Part 1: Designing your Google Analytics UTM structure
- Part 2: Automatically tagging Eloqua emails (External Tracking)
- Part 3: Passing GA data through Eloqua forms (this page)
- Part 4: Making GA data usable in dashboards and segmentation
Why capture UTM parameters inside Eloqua
Your web analytics team sees the UTM data inside Google Analytics, but as marketers you also need that same information inside Eloqua. This is because it allows you to:
- segment based on real acquisition data
- attribute form submissions to channels and campaigns
- report performance downstream in Salesforce or BI tools
- understand how content performs across different email variants
To do that you need Eloqua to store the GA parameters against the contact or the form submission record.
The easiest and most scalable method is to capture the parameters in hidden fields inside the form.
Step 1: Add UTM hidden fields to your Eloqua form
In this example we keep the visible fields simple with only Email. In your production forms you may have many more visible fields. The important part is adding the hidden fields.
Add the following five custom fields to your form:
- utm_source
- utm_medium
- utm_campaign
- utm_content
- utm_term
These fields will be populated automatically by JavaScript before the form is submitted.
Step 2: Add JavaScript to detect UTM values on the landing page
Paste the following JavaScript into your landing page. It will extract UTM values from the URL and push them into the hidden fields.
var defaultHiddenFieldNameValue = "NoData";
function getQueryStringParamValue(strQStrParam) {
var strURL = document.location.href;
var strQStrParamValue = "";
if (strURL.indexOf('?') != -1) {
strQStrParamValue = strURL.substr(strURL.indexOf('?') + 1);
if (strQStrParamValue.indexOf(strQStrParam) != -1) {
strQStrParamValue = strQStrParamValue.substr(strQStrParamValue.indexOf(strQStrParam));
strQStrParamValue = strQStrParamValue.substr(strQStrParamValue.indexOf('=') + 1);
if (strQStrParamValue.indexOf('&') != -1)
strQStrParamValue = strQStrParamValue.substr(0, strQStrParamValue.indexOf('&'));
return strQStrParamValue;
} else {
return defaultHiddenFieldNameValue;
}
} else {
return defaultHiddenFieldNameValue;
}
}
var form = "MY_FORM"; // Replace with your form name
function setCampaign() {
var elqForm = document.forms[form];
elqForm.elements['utm_source'].value = getQueryStringParamValue('utm_source');
elqForm.elements['utm_medium'].value = getQueryStringParamValue('utm_medium');
elqForm.elements['utm_campaign'].value = getQueryStringParamValue('utm_campaign');
elqForm.elements['utm_content'].value = getQueryStringParamValue('utm_content');
elqForm.elements['utm_term'].value = getQueryStringParamValue('utm_term');
}
window.onload = setCampaign;
This script runs on page load and populates the hidden fields automatically before the user submits the form.
Optional advanced improvements
There are several enhancements you can layer on top:
- Fallback to cookies so that UTMs persist across multiple pages
- Overwriting logic to decide whether to keep first or last touch values
- Form submit interceptor so that the script waits for the form to be ready
- Using session storage for performance and clarity
In Part 4 I show how these captured values can drive attribution reporting inside Eloqua and CRM.
Testing checklist
- Add a URL like: ?utm_source=test&utm_medium=email&utm_campaign=demo
- Load the landing page
- Inspect the hidden fields to confirm the values populated
- Submit the form
- Check the form submission data in Eloqua
- Map the fields to Contact or CDO records as needed
Conclusion
You now have a complete method to capture Google Analytics UTM parameters into Eloqua using hidden fields and JavaScript. This closes the loop between channel acquisition and form conversion.
In the final part of the series I show you how to make this data usable for reporting, attribution and segmentation.
For now you have fully connected GA to Eloqua at the landing page level.
Need help building enterprise grade GA and Eloqua attribution
I support organisations that need clean, reliable and automated tracking inside Eloqua. If you want your data wired correctly, let me know.