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:

Key Benefits

Extend the Customer Data Hub

You can use 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

Functions can be triggered on processed events or on processed visitors. The function is invoked after the event or visitor is 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 and 10 seconds execution time. If either 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 * 1min = execution rate of 60,000 invocations per minute 

Execution time = 1000 invocations/second * 100ms / 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 800ms per invocation. That means that our execution time is increased by 8.

Execution time = (1000 inv/s * 100ms / 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 greatert than 8 hours/minute maximum. Function invocations may be throttled.

Data Provided to Functions

The Tealium module exports five named exports for functions to import: auth, event, visitor, store, and tealium. The named exports are objects containing data that can be used in the function.

The auth object provides a method to get an authentication token from a service provider such as Facebook or Google. The token is typically a string of characters that is used to identify a user or an application. Tealium functions must provide an authentication token to make API calls to Facebook or Google. To get an authentication token, you need an account with the service provider.

The event object contains the event data from the event feed. The visitor object contains the visitor data from the audience feed. The store object provides a method to get a global parameter. The tealium object 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.

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