View a markdown version of this page

Working with MediaTailor Monetization Functions - AWS Elemental MediaTailor

Working with MediaTailor Monetization Functions

With MediaTailor Monetization Functions (Functions), you can customize how AWS Elemental MediaTailor manages session data, builds ad requests, and selects ads during ad insertion. Functions let you call external APIs, transform data with expressions, modify ad decision server (ADS) request parameters or player parameters, and filter, reorder, or supplement the ads that are inserted into the stream. You don't need to deploy or manage custom infrastructure.

Functions use JSONata, a lightweight query and transformation language for JSON data, to evaluate expressions. You write JSONata expressions to read session data, transform values, and define output. For the complete list of supported JSONata functions, see JSONata expression reference.

Use Functions when you need to:

  • Enrich ad requests with viewer data. Call an identity service at session start and include the resolved identity in every ADS request for personalized ad targeting.

  • Customize ADS request parameters. Dynamically set the ADS URL, headers, or body based on session data, SCTE-35 signals, or external API responses.

  • Run A/B tests across ad servers. Split traffic between different ADS endpoints based on session attributes or random assignment.

  • Build multi-step enrichment pipelines. Chain multiple functions together to fetch data from one API, transform it, and pass the results to the next step.

  • Target ads based on video content. Query Elemental Inference for IAB content classifications and GARM brand safety signals, then pass contextual metadata to your ad decision server for contextual ad targeting.

  • Filter or reorder the ads returned by your ADS. Remove ads from specific ad systems for competitive separation, or reorder ads before MediaTailor selects which to insert.

  • Fill unfilled ad time with your own ads. Detect underfilled ad breaks and fetch house ads or promos from a secondary VAST endpoint to fill the remaining time.

How Functions fit into the MediaTailor workflow

When a viewer starts a playback session, MediaTailor evaluates your functions at specific points in the ad insertion flow called lifecycle hooks.

  1. You define a function and attach it to a playback configuration through a function mapping.

  2. MediaTailor runs the function at the designated lifecycle hook.

  3. The function reads session data, optionally calls an external API, and writes results that MediaTailor uses during playback processing.

Tip

If you are new to Functions, start with the Quick start guide, then read Lifecycle hooks. For expression syntax and complete examples, see JSONata expression reference and Function examples.