Back

Tealium Functions is a serverless environment in which you can build and run custom JavaScript functions that are hosted on the Tealium platform. Functions are small blocks of JavaScript code that you can use to extend the functionality of the Tealium Customer Data Hub.

In this article:

Function Types

Tealium currently supports the following function types:

  • Data Transformation Functions – Functions that are triggered after an event is received by Tealium Collect.
  • Event or Visitor Functions – Functions that are triggered after an event or visitor is processed.

To use functions that are triggered by processed events, you must have EventStream enabled. For more information, see Introduction to EventStream. To use functions that are triggered by processed visitors, you must have AudienceStream enabled. For more information, see Introduction to AudienceStream.

The Data Transformation Functions feature is currently in early access and only open to select customers at this time.  For more information, see ***LINK to experiments announcement.

Key Benefits

Extend the Customer Data Hub

You can use data transformation functions to modify incoming event data. For example, a data transformation function can use the flatten() utility to convert a nested object to an object with all data on a single level.

You can use event and visitor functions to retrieve data from other systems, augment Tealium data, or send data to other endpoints. If a function modifies visitor or event data, the changes are local to the function and do not affect the Tealium data. Functions can send the modified data to Tealium Collect, where it is processed again and the changes are reflected in Tealium data.

There is a cost associated with sending event or visitor data to the Collect endpoint because the number of events is increased each time data is sent.

Serverless Environment

In the serverless functions environment, functions are hosted on the Tealium Platform. Tealium manages the servers and platform software and you can focus on implementing functions for your unique data needs.  Resources, such as memory, are allocated automatically each time a function is invoked.

Triggers

Data transformation functions are invoked after an event is collected from the data source and before the event is processed, as shown in the following data pipeline diagram. Data transformation functions support all event types except for file import events.

data-source-event-collected.png

Only one data transformation function can be triggered for an event. If multiple functions are triggered for an event, only the function with the earliest creation date is executed.

Event and visitor functions are invoked after the event or visitor has been processed, as shown in the following data pipeline diagram.

ProcessedEventFeed_Full.png

Functions Execution Environment

The functions execution environment is built on the GraalVM JS runtime and runs ECMAScript 2020 compatible code. Functions are limited to 32 MB of memory. Data transformation functions are limited to 150 ms execution time. Event and visitor runctions are limited to 10 seconds execution time. If the memory or execution time limit is exceeded, an error message is written to the log file.

There are also limits on compute, network, and other resources, as follows:

  • Maximum Execution rate: 180,000 events per minute
  • Maximum Execution time: 8 hours per minute

Tealium may briefly throttle function invocations if they start to utilize too many resources within a 1-min time frame. Throttling is applied on an account level, meaning that aggregated values of all configured and enabled functions are counted.

Execution Rate and Execution Time: Example 1

In this example, we assume that function that communicates with external APIs takes about 100 ms per invocation. In addition, we assume there is only one function configured for the account and the average execution rate of this function is 1000 invocations per second. 

The execution rate and execution time within a 1-minute time window are as follows:

Events per second = 1000 * 60 * 1 min = execution rate of 60,000 invocations per minute 

Execution time = 1000 invocations/second * 100 ms / 1000 = 100 minutes = 1.66 hours execution time per minute

In this case, the execution rate and execution time are both below the limits.

Execution Rate and Execution Time: Example 2

In this example, we assume that external API performance temporarily degrades, and the function execution time is 800 ms per invocation. That means that our execution time is increased by 8.

Execution time = (1000 inv/s * 100 ms / 1000) * 8 = 800 minutes = 13.28 hours of execution time per minute

The execution time in this case is 13.28 hours per minute, which is greater than 8 hours/minute maximum. Function invocations may be throttled.

Data Provided to Functions

The data provided to a function varies depending on the function type.

Data Transformation Functions

Data transformation functions have one input parameter, TealiumEvent, which contains the event data from Tealium Collect. In addition, the Tealium module exports the flatten() utility for data transformation functions, which converts a nested object into a new object with no nesting.

Event or Visitor Functions

The Tealium module exports five named exports for event and visitor functions to import: auth, event, visitor, store, and tealium.

Export Description
auth Provides a method to get an authentication token from a service provider such as Facebook or Google.
event Contains the event data from the event feed.
visitor Contains the visitor data from the audience feed.
store Provides a method to get a global parameter. 
tealium Provides a method to send an event to Tealium Collect.

Functions Code Editor

The Tealium Functions code editor provides tabs for creating, configuring, testing, and monitoring functions, as well as viewing logs and getting an authentication token.

functions-code-editor.png

Code Tab

When you create a new function, the Code tab displays example function code with explanations in comments. You can modify the example code, or replace it with your own code.

Monitoring Tab

The Monitoring tab displays the following function statistics for the last hour, 12 hours, day, 7 days, or 30 days:

  • Invocations
  • Average Execution Time
  • Errors

Logs Tab

The Logs tab displays a list of log files from function execution. Log files are kept for 30 days.

Configuration Tab

Use the Configuration tab to change the function name, add or change notes about the function, or change the event or audience that triggers the function. The feed cannot be changed after the initial function configuration.

Test Tab

Use the Test tab to create a test payload and test your function. You can modify the example payload shown in the Test tab, or use test data from your website. For more information on obtaining test data from your website, see Writing Functions. Test results and log files are available after the function is executed.

Advanced Tab

Use the Advanced tab to assign authentication tokens to a function.

Public