Custom Content

Extend your emails with programmable content!

This document covers the following:

  • Intro to Custom Content

  • API Reference

  • Step by Step Example

Custom Content Intro

ustom Content lets you easily write short scripts that insert content into emails. This content is completely custom. It can be whatever you need. Here are some examples: 1. Insert complex custom content, e.g. bar-codes or QR-codes 2. Insert content powered by external data, e.g. a full itemized bill 3. Loop over content, e.g. showing a piece of content for every data-point in an API 4. ANY content you cannot easily do with Eloqua! ‍ Creating a Custom Content block is incredibly simple: place it in your email. A code editor opens. 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 55 second demo:

Intro Video:

API Reference

eloqua.log

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

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

eloqua.each

Every Custom Content starts with eloqua.each(...).

This function will loop over all the contacts sent by Eloqua. The contact object properties & functions listed below are available inside this wrapper. The contact object inside this loop will refer to each contact, one at a time.

contact.done

The contact.done function sends your generated HTML back to Eloqua.

contact.fields

The contact.fields object lets you access the contact's fields from the Eloqua database:

Fields must be accessed using their internal field-name.

The editor's autocomplete makes this extremely easy. Just start typing and all the fields in the database (including custom fields) will be available & type-checked.

contact.error

The contact.error function elegantly handles errors:

Specifically, it does 2 things:

  1. It lets Eloqua know your function has errored (for that contact). If you chose a 'route errors' step in your campaign/program, the contact will be sent there.

  2. The error message will be elegantly displayed when you test your function, or in the Log tab.

Examples

Basic Example

This extremely basic example just says hello to a contact by name. (This is equivalent to a heading with a field-merge in Eloqua).

API Example

The below example demonstrates using a Custom Action to retrieve some information.

Specifically - we use an API to simply display the weather in the contact's current city. This could be any API for any service (including your internal business tools).

Looping Over Data

Please note that the same example could easily be modfiied to loop over data from an API, to show some content for each data-point. E.g. to show an itemized bill, or a full shopping-cart list, or a personalised newsletter of variable length, a set of offers, etc.

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 Instant Marketing global settings. An object with all the global settings is available as eloqua.globals - therefore you can access whatever global properties you setup: