Eloqua Blog · Development
Eloqua Development: Automatically Add Query String To All Page Links
A simple Eloqua landing page fix for preserving analytics parameters when someone clicks away from the page instead of submitting the form.
Background To The Problem
One of the big analytics problems with Eloqua landing pages is what happens when a contact arrives from a campaign but does not convert. If they click another link on the landing page and go back to the website, the campaign path can break.
All Eloqua campaigns use different sources and mediums to drive contacts to an Eloqua landing page.
- Social media
- Search engine adverts
- Banner adverts
- Other campaign channels
Why Query Strings Matter
Inbound links from each source and medium should carry a query string so marketers can analyse campaign performance. Without those parameters, source, medium, campaign and content reporting become much harder to trust.
Eloqua
https://forms.xyz.com?utm_campaign=FY19_Q1_CAMPAIGN&utm_source=Eloqua&utm_medium=email&utm_content=EDM1
https://forms.xyz.com?utm_campaign=FY19_Q1_CAMPAIGN&utm_source=LinkedIn&utm_medium=Social&utm_content=sm_banner
https://forms.xyz.com?utm_campaign=FY19_Q1_CAMPAIGN&utm_source=Twitter&utm_medium=Social&utm_content=Version1
In the ideal journey, the user clicks through to an Eloqua landing page, submits the form, and is taken to the follow-up Eloqua landing page. But landing pages often contain other links, and those links can take the visitor away before the form submission happens.
The Tracking Gap
A good example is an Eloqua landing page that asks for a business email address but also includes a series of links below the form. Those links can take the visitor away from the Eloqua page before the form is submitted.
Add a normal tracking query string to the landing page URL, then hover over a link at the bottom of the page. The outbound link does not automatically include the inbound query string.
If the user clicks away, analytics can lose the campaign context. That creates a reporting blind spot for source, medium, campaign and content.
Problem Defined
We need a way to make any query string that brings a user to an Eloqua landing page get added to every outbound link on that same landing page.
The practical outcome
Visitors can click from the Eloqua landing page to another site page while still carrying the original campaign parameters with them.
<script type="text/javascript">
window.onload = function () {
let querystring = window.location.search;
if (querystring.startsWith('?')) {
querystring = querystring.replace('?', '');
}
for (let a of document.querySelectorAll('a')) {
a.href += (a.href.match(/\?/) ? '&' : '?') + querystring;
}
};
</script>
Solution In Place
Insert the code in the head section of the Eloqua landing page. Once it is in place, hover over the same link and the outbound URL should now contain the campaign query string.
That small change keeps the analytics trail intact when the visitor leaves the Eloqua page through an ordinary link rather than through the form journey.
Related article
Google Analytics Tracking On Eloqua Forms
A companion article on building and using analytics query strings with Eloqua forms.
Read articleRelated article
Eloqua Form Spam Protection
Another practical Eloqua landing page and form implementation guide.
Read article
