Data Element Types

A data element type library module has one goal: retrieve a piece of data. How this piece of data is retrieved is up to you. Perhaps you would like to allow Launch users to retrieve a piece of data from local storage? A cookie? A DOM element?

The module exports should look like this:

module.exports = function(settings) { ... };

Let’s assume that we would like to allow users to retrieve a piece of data from a local storage item named productName. Our module may look like this:

module.exports = function(settings) {
  return localStorage.getItem('productName');

Now what if we wanted to make the local storage item name configurable by the Launch user? In our view we would allow the user to input a local storage item name and then save the name to the settings object. The object might look something like this:

  itemName: "campaignId"

In order to operate on the user-defined local storage item name, our module would need to change to this:

module.exports = function(settings) {
  return localStorage.getItem(settings.itemName);

Default Value Support

Be aware that users have the option to configure a default value for any data element. If your data element library module returns a value of undefined or null, it will be automatically replaced by the default value the user has configured for the data element.