Quantcast

Eloqua Technical: How to capture exactly which campaign, medium, etc, a lead used to come on to your website even though they navigated around several pages before conversion.

Oct 7, 2023

I got asked by a subscriber how they could track UTM parameters on the first touch to their website from all mediums, campaigns, etc because contacts where coming to their website, navigating around and then submitting forms.  After I helped them they no longer had a massive black hole in their campaign analytics.  Here is exactly how to do it.

Greg Staunton

Problem

I want to track which campaign, i.e. google ads, email, etc that a lead came on to our website before converting several page views later.  I also want to create a contact in Eloqua and drop the tracking cookie.  How can I do this?

Here is a diagram of exactly what I want:

Eloqua GTM data layer

Solution

Eloqua Conversion Tags using Google Tag Manager

 

Introduction

Let’s break this down.  In this article I am going to prove 3 things:

  • Add UTM marketing source parameters to a cookie to retrieve them later at the point of conversion.
  • Take user submitted values from forms.
  • Create a Javascript that will successfully send the above data to Eloqua.

I am glad to say that I was able to achieve all of these things technically, and this article outlines how that is achieved in GTM, and how it could be replicated across your entire website.

 

Get the UTM marketing source parameters into a cookie

This is achievable by creating a variable that takes values from query string, and then setting a cookie when these variables are detected.

Create new User-defined variables of type ‘URL’ and select component type ‘query’. Enter the key of the query string variable you want to use, eg: ‘utm_medium’.

Create a new trigger to fire on page load when ‘utm_medium’ does not equal ‘undefined’.

Create a tag to set the cookie referencing the query string parameters, eg:

<script>

document.cookie = “utmParams={{utm_medium}}_{{utm_source}}_{{utm_campaign}}_{{utm_content}}; path=/; domain=.acme.com;”;

</script>

In this example, the cookie will persist across all acme.com subdomains. You can then create a ‘1st party cookie’ variable in GTM which simply references the name of the required cookie.

 

User submitted values in the forms

Using the login page on a different subdomain from the main website I were able to create a custom javascript variable which referenced the field in the form we were interested in, eg:

<script>

function(){

var loginEmail = $(‘#Email’).val();

return loginEmail;

}

</script>

This is achievable where form fields have specific IDs. Where not, we can also get these using GTM data layer variables, in this example:

gtm.element.2.value

Creating the conversion tag for Eloqua

The below code references the GTM variable {{Login Email}} and successfully sends it to Eloqua as a conversion. We can add more fields and add them to the string.

Using this example as a template, we could create tracking events for the various conversions on SSE and send the required data to Eloqua on each form submit.

<script>

var emailStr = ‘{{Login Email}}’

var htmlStr = ‘https://s25071713.t.en25.com/e/f2.aspx?elqFormName=GS_GTM_TEST&elqSiteID=25071713&EmailAddress=’ + encodeURIComponent(emailStr);

var req = new XMLHttpRequest();

req.open(‘GET’,htmlStr, true)

req.send()

</script>

Conclusion

This approach has been a great success for the client.  They have razer sharp reporting no matter what the user does.  We implemented some other things so we could record first and last touch for greater reporting capabilities though that is a story for another day.

Here is all the code you need to get this holy grail of tracking set up.

<!– this is how we document a session level cookie using GTM–>

<script>

document.cookie = “utmParams={{utm_medium}}_{{utm_source}}_{{utm_campaign}}_{{utm_content}}; path=/; domain=.acme.com;”;

</script>

 

//this code references the ID of the email address field on the login form. We can replicate this for all form fields with an ID

function(){

var loginEmail = $(‘#Email’).val();

return loginEmail;

}

 

<!– This code sends the required URL to Eloqua, it’s just var htmlStr that needs to change for each different form. –>

<script>

var emailStr = ‘{{Login Email}}’

var htmlStr = ‘https://s25071713.t.en25.com/e/f2.aspx?elqFormName=GS_GTM_TEST&elqSiteID=25071713&EmailAddress=’ + encodeURIComponent(emailStr);

var req = new XMLHttpRequest();

req.open(‘GET’,htmlStr, true)

req.send()

</script>

If you would like me to email you this content so you can use the code or content and images for a presentation click here.

Eloqua Guide: How to use the Eloqua Sandbox

Eloqua Guide: How to use the Eloqua Sandbox

In the ever-evolving landscape of digital marketing, it's crucial to have a safe and controlled environment to test new strategies, campaigns, and configurations before implementing them in your live Eloqua instance. Eloqua offers a sandbox environment for this...

error: Content is protected !!