Custom Audience

Import contacts on demand

This document covers the following:

  1. Intro to Custom Audiences

  2. API Reference

  3. Step by Step Example

Custom Audience Intro

The Custom Audience lets you create a custom campaign/program step, which will import contacts on demand. The most common use-case is importing & updating contacts: - Segment contacts outside Eloqua e.g. a data-warehouse - Import/segment contacts from an internal or external system ‍ Creating a Custom Audience is incredibly simple: place it. Click to open a code-editor. Change a few lines of JavaScript. Then click 'test' to check it works. It really is that simple. And if you prefer not to do the JavaScript, help is available. We recommend watching this 50 second demo:

Intro Video:

API Reference


You can use eloqua.log("Message here...") anywhere in your action.

This built-in function logs whatever you pass to it. This message will be visible in 2 places:

  1. When you test your feature, it will display in a blue info box

  2. In the 'Logs' tab after your feature runs in a campaign or program


The eloqua.audience function sends an audience back to Eloqua. It does 2 things. 1. The contacts will be imported/updated into your Eloqua database 2. The contacts will be added to your campaign or program Therefore the Custom Audience is useful for both importing and segmenting contacts.

In the above example, eloqua.audience() is passed two hard-coded contacts. These contacts will be created if they do not exist in Eloqua, and whatever fields you pass will be updated. You return an array of contacts. Each contact object needs to have Eloqua's internal fieldname as the key, and the update as the value. ‍The editor makes this process much easier. In the eloqua.audience() you can start typing any field - and Instant Marketing will autocomplete the internal field-names for you! This autocompletion support is actually smart enough to know all the custom fields in your specific instance, and will highlight an error if you pass the wrong type. (E.g. if you try to pass a string to an Eloqua Number field).


Basic Example

This basic example creates/updates one contact, setting their name to 'Bruce Wayne'.

API Sample

The below sample demonstrates using a Custom Audience to retrieve an audience from an API.

Real API Example

The below example includes an extra step to map results.

This is a real, working example which queries a sample-data site and fetches contacts.

Advanced Topics

Config Object

In the 'Action' tab if you click on the more icon ('...'), you can select Advanced Settings. One of these settings is a config object. This is designed for a situation where you want to re-use the same code, but pass different "settings" into it each time. ‍ The entire config object is available as eloqua.config - therefore you can access whatever properties you give it:

Again - the config is unique to each instance of your app, and is designed to allow re-use.

Global Settings Object

You may want to have some values stored outside of your code. E.g. API keys. This can be useful for security (less visible), and also means they can be centrally maintained even if they are used in many functions. You can set global config through the Just Add Features global settings. An object with all the global settings is available as eloqua.globals - therefore you can access whatever global properties you setup: