Skip navigation

Do It

2 Posts authored by: Donald Seigler

How Would You Rate the Integrity of the Data in Your Database?

If you are like most digital marketers, your database is full of incomplete or "dirty" data.  I spend a lot of time scrubbing client's Eloqua contact tables to weed out bogus email addresses, properly and consistently format phone numbers and find other fields that lack necessary information pertinent to a successful marketing campaign.

Now I am not complaining, afterall it is job security, but wouldn't it be great if the data going into your database had checks in place to prevent adding useless or incomplete data?

"If you are not using good form validation to ensure required fields are being filled out or that emails and phone numbers are entered correctly and properly formatted, you are adding costs and inefficiencies to your marketing efforts."

Maybe you are not aware of form validation scripts, or perhaps you do not have the technical resources available in which to implement good validation.  Whatever the case, the development team at Iron-Point Marketing is sharing its latest validation script to help you improve your data integrity.  The best part is that it is easy to use and integrate with your marketing forms and you don't need to have any prior coding experience!

Customizable Options and Features

The Plug-n-Play Validator Script allows you to set custom error messages for any given field to override the default messages.  When an error is detected on a field it will display the message inline underneath the field rather than being displayed in an ugly pop-up box.  The script uses <h5> tags to contain the error message, so they are easily targeted with CSS to style them within your form design.

You will also have the option to simply display only the first error that is found in any given form submit.  You can alternatively choose to display all errors found in the form on each submit.

Regarding each field in your form (text, textarea, select, checkbox, etc.), you can set them to be required or not. In addition, you can set fields to check for proper formatting on email addresses, urls and phone numbers. Your users will be able to enter phone numbers in a variety of formats (, (xxx) xxx-xxxx, etc.) but the script will format the input consistently before going into your database as (xxx) xxx-xxxx.  You may also specify if you want to validate domestic, international or both types of numbers.

The script has other options to validate field input such as for alphabetical, numeric or alpha-numeric values only.  It also contains an option to specify any custom character set that you might want to allow in your inputs.

Finally, a Plug-n-Play Form Validator Courtesy of Iron-Point Marketing

To see the script in action or download the complimentary Plug-n-Play Form Validator Script visit my blog.

Once you plug in the script the remainder of the setup takes place in the form's HTML. Now that was easy, right?

The Scenario


Let's say you want to execute an email campaign for a select list of contacts, rewarding them with a free t-shirt for being a valued customer. In order for the contact to receive the t-shirt they must fill out a form by clicking a link in your email. But then somebody outside of your select list gets wind of the promotion and posts a link to your form on a “deals” website. This action drives unwanted traffic to the form and obligates you to distribute more free t-shirts than your budget allowed! Not a pretty scenario is it?




So how do you set up your form to prevent these unwanted visitors from crashing your party? Well, it's a process, but it can be done with the combination of Eloqua Visitor Web Data Lookups, Eloqua Web Contact Group Lookups and the use of query strings in your email links. Yep, that is all it takes, along with a little JavaScript savvy, to create a super secure form that only the contacts you specify are allowed to view the form.


Eloqua Setup


First thing's first. To start the process you will of course need to setup your email in Eloqua and append a query string to each link you have directing your contact to the free t-shirt form. Let's say it looks something like:

In addition, Eloqua will append a unique code to the end of this query string to identify your contact. So the final link in your email will look something like this:




As part of the process we will check and verify that the 'promo' variable is contained within the query string when the form is loaded.  If it is, then we will allow the visitor to view the form, but if this value is not present, we will redirect them to your home page and prevent them from viewing your form.


Second, you will need to create a new Contact List (Contact Group in E9) and add to it all of the contacts you have targeted for the email promotion.  We will use this Contact List to verify if the visitor is in our campaign or send them along their way if they are not. While you are setting this up, go ahead and setup a second Contact List to place those contacts that sign up for the t-shirt as we will use that List to prevent multiple form submissions from the same contact.  Nifty, isn't it?


Next, you will need to setup both a Visitor Web Data Lookup with a contact view to return your visitor's email address and a Contact Group Web Data Lookup that will return the unique code for your Contact Lists.  The unique code for your Contact Lists will be displayed on your Contact List details page once you create it.


Finally, to complete the Eloqua setup you just need to add a Processing Step to your Eloqua form that places each contact that submits the form into the second Contact List you created.  That's it!  Well, at least on the Eloqua side of things...


Coding Your Form


Here I will assume you have setup a standard form before, so we won't get into the HTML/CSS specifics.  Suffice it to say we have a short form that looks something like this:


<form action="" name="reward" method="post"> 
    <!-- Hidden fields -->
    <input type="hidden" name="elqFormName" value="reward">
    <input type="hidden" name="elqSiteID" value="XXX">
    <input type="hidden" name="C_EmailAddress" id="C_EmailAddress" value="<eloqua type='emailfield' syntax='EmailAddress' />">
        <label for="size">T-Shirt Size:</label>
        <select name="size">
            <option selected="selected">Please Select Your Size</option>
            <option value="1">Small</option>
            <option value="2">Medium</option>
            <option value="3">Large</option>
            <option value="4">X-Large</option>
        <label for="color">T-Shirt Color:</label>
        <select name="color">
            <option selected="selected">Please Select Your Color</option>
            <option value="1">Red</option>
            <option value="2">Green</option>
            <option value="3">Blue</option>
            <option value="4">Black</option>
        <label for="Pros">Tell Us Why You Love Us:</label>
        <textarea name="Pros" cols="60" rows="5"></textarea>
    <input type="submit" value="Submit">


Don't forget to set your Eloqua Site ID (XXX) in the form action attribute and in the “elqSiteID” hidden field value.  Also, when customizing your form replace the form name “reward” to your form HTML name in the form tag name attribute as well as the "elqFormName" hidden field value.


I thought I'd mention...


One more thing to mention in this form setup is that we made the email field a hidden field.  Why you ask? Well, because we already have a relationship with these contacts and know their email address, we won't waste their time by asking them to enter yet another time.  A good user experience rules! We will use Eloqua functionality to fill out the email field when they click through to the form. 


It is easy and painless and we will use the email value from the field when it is submitted to put them into the second Contact List we made before so we can ensure they only get one t-shirt.


Detecting the Query String


Now that that is out of the way, let's move on to the fun part! We will start with the JavaScript to verify that the query string is present and that it contains the variable “promo” and that it is set to “tshirts.” This code will need to be placed between your  <head></head>  tags so it is evaluated immediately upon arrival to the form.


<!-- Query String Confirmation Script -->
<script type="text/javascript">
    var queryParams = {};
        (function () {
            var match,
                pl     = /\+/g,  // Regex for replacing addition symbol with a space
                search = /([^&=]+)=?([^&]*)/g,
                decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
                query  =;

            while (match = search.exec(query))
               queryParams[decode(match[1])] = decode(match[2]);
    if (!queryParams["promo"] == "tshirts") {
        window.location = ''; 


This code was borrowed from Andy E. posted at Stack Overflow.


Without getting too technical, this code will check for and read the query string then verify if the variable “promo” exists.  If it does, the rest of the page will continue to load, however, if it does not exist it will forward the visitor to the My Company home page.


To customize the script for your promotion, simply change the “promo”  and the "tshirts" values on the line where it says

if (!queryParams["promo"] == "tshirts") {


to match your query string variable and value, and change the


to the url where you will be redirecting your visitor.


This step will eliminate most of the link reposts that can occur around the web and will generally stop outsiders that do not receive an email with query strings in the link.  But, it is not fool-proof in and of itself, so there is more work to do.


Verifying the Visitor is an Intended Contact


The first script we will cover is your Eloqua Web Data Lookup settings.  This is where you will customize your form to work with your Web Data Lookup IDs and the Contact List Unique IDs that will be used in the scripts that follow.  The Data Lookup Scripts that follow will also be placed in the  <head></head> section of your form, simply copy and paste and then change the values in the first section to those for your Eloqua instance and other Eloqua elements.


The following code was borrowed from Eloqua's Chris Mapili and modified for Contact Group Data Lookups.


<!-- Eloqua Data Lookup Scripts -->

<!-- SCRIPT SECTION 1:  Variables that need customizing based on your Instance of Eloqua-->
<script type="text/javascript">

    // The Site ID of your Eloqua Instance
    var EloquaSiteID = "XXX";
    // Path to elqCfg.min.js
    var EloquaScript = ""; 
    // LOOKUP A: The ID of your Visitor Web Data Lookup
    var LookupIdVisitor = "181b80bf-b527-4c85-9d6b-4ca363afb999";
    // LOOKUP B: The ID of your Contact Group Data Lookup
    var LookupIdPrimary = "49d62966-9e8b-4104-84d7-227be99f9999";
    // Unique field's HTML Name from LOOKUP A (usually V_Email_Address)
    var VisitorUniqueField = "V_Email_Address";
    // Unique field's HTML Name from LOOKUP B (usually C_EmailAddress)
    var PrimaryUniqueField = "C_EmailAddress";
    // The ID of your Eloqua Form
    var EloquaFormID = "reward";
    //CONTACT LIST A:  The unique ID of the Contact List for Intended Contacts
    var intendedContactsListID = "181b80bf-b527-4c85-9d6b-4ca363afb999";
    // CONTACT LIST B:  The unique ID of of the Contact List for each form submit
    var promoParticipantsID = "181b80bf-b527-4c85-9d6b-4ca363afb999";



The second Web Data Lookup script involves dynamically building scripts from Eloqua that are populated with your  Web Data Lookup values for your visitors.  You will not need to make any changes to this section, simply cut and paste it immediately after the first section above.


<!-- SCRIPT SECTION 2:  Standard Eloqua Asyncronous Tracking Code | The unique values have been placed in Variables (EloquaSiteID and EloquaScript) -->
<script type="text/javascript">
    var _elqQ = _elqQ || [];
    _elqQ.push(['elqSetSiteId', EloquaSiteID]);

    (function () {
        function async_load() {
            var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true;
            s.src = EloquaScript;
            var x = document.getElementsByTagName('script')[0];
            x.parentNode.insertBefore(s, x);
        if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
        else if (window.attachEvent) window.attachEvent('onload', async_load);


The third Web Data Lookup script will determine if your visitor is in the Intended Contact list or has already submitted the form. If they are not part of the Intended Contact list, they will see a message that the offer is only valid for selected contacts and that they will be redirected to the My Company home page. Furthermore, if they have already submitted the form, they will get a message that says they have already specified their t-shit size and color and that they will be redirected to your home page. 


Just copy and paste this script in your <head></head> section directly following section two above. All you will need to customize in this section are the messages you want to display for both not being in the Intended Contact List and already having placed their t-shirt order, and the URL of the page(s) where you want to redirect the visitor.


<!-- SCRIPT SECTION 3:  Eloqua Contact Group Data Lookups -->
<script type="text/javascript">
    function groupLookup() {
        var intendedContact = GetElqGroupMembershipStatus(intendedContactsListID);
         var inGroup = GetElqGroupMembershipStatus(promoParticipantsID);
        if (intendedContact != true) {
            alert("This offer is only valid for selected contacts.\nYou will now be redirected to the My Company home page.");
            window.location = ''; 
        if (inGroup == true) {
            alert("You have already specified the size and color of your t-shirt. Thanks!\nYou will be redirected to the My Company home page.");
            window.location = ''; 


Finally, in the fourth section the script will read the Eloqua Web Data Lookup values returned by Eloqua.  First it will find the visitor's Eloqua cookie and find the visitor by email address.  Then, having identified the visitor, it will look for the Contact Group data and fire up the script in section three to verify the visitor is on the intended contact list.  You will not need to customize this code, simply copy and paste it into your <head></head> section immediately after section three.


<!-- SCRIPT SECTION 4:  Eloqua Web Data Lookups -->
<script type="text/javascript">

    // SetElqContent is triggered by the Data Lookup Scripts automatically.  The "FirstLookup" modification allows for the Visitor Lookup to trigger the second Lookup (Contact/Datacard/Prospect/Company)
    var FirstLookup = true;
    function SetElqContent() {
        if (FirstLookup) {
            //LOOKUP B:  Eloqua Contact/DataCard/Prospect/Company Data Lookup from Email Address
            _elqQ.push(['elqDataLookup', escape(LookupIdPrimary), '<' + PrimaryUniqueField +'>' + GetElqContentPersonalizationValue(VisitorUniqueField) + '</' + PrimaryUniqueField + '>']);
            FirstLookup = false;
        } else {
            //This is triggered the after Lookup B fires.  LoadFields starts the field prepoulation process.

        // LOOKUP A:  Eloqua Visitor Data Lookup from Cookie  -  Ensure VisitorUniqueField is pulled in the Profile View
        _elqQ.push(['elqDataLookup', escape(LookupIdVisitor), '']);   
<!-- End Eloqua Data Lookup Scripts -->


There you have it!


Now you have a gated form that will only allow those contacts you intend to view the form actually see the form. But wait! What if your intended contact is on a brand new machine and does not have an Eloqua cookie needed to identify them based on your Contact Group Web Data Lookup?


Well, as it turns out, the preceding Eloqua script will know there is no cookie and lay one down based on the Eloqua unique ID provided in the query string in your email links.  But, the form will load before that cookie is laid down and your Web Data Lookups will not fire.  This could be a potential loophole, albeit not highly probable. 


Keep your chin up, there is a way to deal with this and verify that the contact is an Intended Contact! We just need to add one more script to the bottom of the form that will refresh the page after a second enabling it to read the newly laid cookie and proceed with your verification process. Simply paste this code just before the  </body>  tag at the end of your page.


<script type="text/javascript" >
    setTimeout(function() {
        if (!window.GetElqGroupMembershipStatus){


Now you can sleep soundly tonight, knowing your offer won't be blown up by unintended visitors filling out your form for the free t-shirt.  And as a bonus, here is a complete script you can copy and paste then test it out with your Eloqua instance information and unique IDs.  Good luck!


Putting it all together


To see this project put together in a complete HTML file, visit my blog.

Filter Blog

By date: By tag: