Mateusz Dąbrowski

Marketing automation specialist, e‑mail geek and python enthusiast.

Tailor the experience with data logic

Everyone and his boss are talking about personalisation. Most stop at tailoring the content. Don't be that person. Utilise the power of simple data logic and control the user flows.

Article outline

  1. Review the use cases possible thanks to the tailored data logic
  2. Check easy to implement script examples
  3. Create field merge fueled conditional user flows


Leverage the data

Most Marketing Automation tools allow you to use the contact and account data for personalisation. Inserting a user-specific value from a data model to landing page or e-mail (Eloqua's field merges)? Creating custom content tailored to the user (dynamic content)? Easy and simple. But you can do so much more!

» Change the structure of the landing page

Part of your subscription centre should be visible only to your clients? Instead of creating and managing two separate pages, you can use field merge to check whether the visitor has any license and unhide product-related data & subscription section.

» Create a genuinely dynamic form

Not keen on asking your customers, again and again, the same questions in your content form? Use field merges to hide form fields that won't give you new knowledge. The shorter the form, the better.

» Enrich your data

You got multi picklist storing information on topics that are interesting to your customers? Want to use white paper download form to add such data point? Sure, Eloqua form processing will be able to append such value, but unfortunately, it is currently not possible to check whether it already is added to that field. You guessed it, field merge with the simple script can fix it.

<span class=eloquaemail>​Field_Merge_Will_Help1​</span>


Script your solution

Time to create a script that will solve the problems mentioned above. Firstly, you will need to get the data from your data model. For Eloqua, the easiest way is to use the field merge. The code is straightforward: <span class=eloquaemail>​Field_Merge_Name1​</span>. The only thing you need is the field merge name. Unfortunately, you can not add the asset name, as Eloqua is using in the code the automatically created HTML name.

In most cases it is very similar to the original field merge name, in some - like field merge created by copying another one - can be a surprise. To be sure you have the correct name I recommended creating an empty HTML landing page and drag and drop the field merge onto HTML editor. It will add whole needed code for you.

To create a script that will allow for three use cases mentioned in the first part of the post, we need one more thing - an id attribute. Some elements will already have it (for example, each form field exists in separate div element: <div id="formElement1" ...>). The rest will need you to add it to the HTML manually.

With field merge and an id attribute name of website element at hand, we can start the (short) scripting.

Hiding elements on the website

Sample code required to hide Email Opt In form field if user is already opted in

Above script has three important lines that deserve some explanation.

window.onload = function () {

» tells the web browser to launch this script only after the whole page loaded.

if ("<span class=eloquaemail>​EmailOptedIn1​</span>" == "True") {

» evaluates the value stored in the data model received via field merge (left side of ==) with another value we choose (right side of ==). In this case, it checks whether Email Opted In for a particular user is set to True (that value may differ in your Eloqua instance depending on what value your administrator has chosen for positive boolean).

document.getElementById("formElement5").style.display = "none";

» looks for an HTML element with id equal to formElement5 and hides it from the user.

With this script, you can both modify the structure of your landing page and alter the Eloqua form visible for the user. Hide some elements, show other, change the style of a web element to make it more prominent on the website. But that is not all!

For example, for our data enrichment use case, we will need to alter the script slightly.

Changing elements on the website

Sample code required to change value of HTML element based on field merge

How to use the above script to enrich your data cleanly? We will need a hidden field inside the white paper download form. In the form HTML look for input attribute of this hidden field (<input id="field6" type="hidden" ...>). The id attribute will be useful again.

var regexSearchValue = /Tax/;

» Here we declare value we want to check in our data model picklist. In this example, we will test whether the user is already interested in Tax topic.

if (regexSearchValue.test("<span class=eloquaemail>InterestedIn1</span>")) {

» Next step is the fastest way to check whether the declared value is already in our multi picklist. If it is, then the script will evaluate the line below.

document.getElementById("InterestEnrichment").innerHTML = "True";

» Finally, in case of the value already being in the multi picklist, we put True inside the hidden InterestEnrichment (or field6) form field. With it done, we can then utilise Eloqua form processing to append new interest conditionally - if hidden form is blank in submission data.


Create conditional logic

Simple manipulation of visibility and values on your landing page is just beginning. You can get even more out of scripted field merges and take control over user & data flows.

Looking for an excellent way to tell your Google Analytics whether the user just downloaded a white paper or did he also wanted to receive product presentation on top of that? Not keen on creating two mirror-like thank you pages with different conversion script? Sure!

Your form should have a processing step that appends date stamp to a data model field in case of the user becoming a lead (asking for a product presentation). This data, apart from being a great source of knowledge for your lead reporting and data processing trigger, will be handy for this solution.

Sample code required trigger Google Analytics conversion dataLayers conditionally

Why? Because you can check how distant in the past the field merged date is. And if it is within minutes, you can be pretty sure the user just became your lead. Which tells the script to push the lead conversion data layer instead of the whitepaper data layer. Simple and quick.
Eloqua is applying the date in their servers timezone (CET/CEST).

Possibilities are endless.

Want to be sure only recognised users will enter your subscription centre? Add e-mail address field merge. If it is empty, it means Eloqua did not recognise this user. JavaScript can automatically redirect him to your subscription centre entry form.

if ("<span class=eloquaemail>​EmailAddress​</span>" == "") {

Want to push some information from a data model to an external page? Field merge that data and use JavaScript to append it to redirect link as a query string.

You can get even more power with using dynamic content (perfect for simplifying javascript logic) or web data lookups (allows you to leverage e-mail group subscription, shared list audience › even on external websites). Imagination is the only limit.

Are you interested in more tricks? Let me know!

Mateusz Dąbrowski — 09.12.2018 — Data Code Automation

Relevant articles