JavaScript is fully in charge of Data Mappings.

Ildar Nurislamov

VP of Engineering
November 3rd, 2021

We added JavaScript support in July'21 for destinations table name selection and webhooks body composition. But we didn't plan to stop there. As of today, we are happy to announce an expansion of JavaScript support in Jitsu: JavaScript Transform comes as a modern and flexible replacement of the Mapping feature.

The Mapping feature with its predefined set of rules served well but has some shortcomings:

  • Complicated – each mapped field requires its UI block, making any rich mapping setup too bloated and very hard to manage.
  • Not flexible – having just four rule types (move, remove, cast, and constant) significantly limits what one can do with the data.
  • Not applied by default – some destination that relies on mapped data (e.g., Google Analytics or Facebook marketing) requires a user to manually apply the appropriate mapping template.

Mapping UX problem
Mapping UX problem

JavaScript Transform solves all this and brings more to the table:

  • Even complicated mapping now can fit a single screen.
  • The power and flexibility of the JavaScript language allow computing new objects or fields based on incoming event data.
  • Given the nature of JavaScript object creation, Transform code may represent the resulting data structure in an obvious form:
const context = $.eventn_ctx || $
const user = context.user || {}
const conversion = context.conversion || {}

return {
  event_name: $.event_type,
  event_id: context.event_id || $.eventn_ctx_event_id,
  event_source_url: context.url,
  user_data: {
    client_ip_address: $.source_ip,
    client_user_agent: context.user_agent,
  custom_data: {
    currency: conversion.currency || $.currency,
    value: conversion.revenue || $.revenue,

In the UI version of Jitsu new Google Analytics, Facebook, and Amplitude destination setups now have the appropriate Transform function initially enabled.

New to Javascript Transform

The following features weren't possible with the previous Mapping implementation:

  • Producing Multiple events based on data of a single incoming event.
  • Selecting a destination table or skipping an event
  • Using predefined variables and functions

Event multiplexing

Let's say Jitsu receives a conversion event with multiple products added to the shopping cart. Now it is possible to break this event into a set of purchase events - one for each product.

Event multiplexing in the shiny new Code Debugger
Event multiplexing in the shiny new Code Debugger

Selecting a destination table or skipping an event

Select destination table with ease by setting one special property of resulting event:

return { ...$, JITSU_TABLE_NAME: "new_events" }

to skip event from processing, simply return null

Using predefined variables and functions

Your transformation code is executed in a context where Jitsu puts some extra constants and functions that you may use:

  • destinationId – constant containing id of current destination
  • destinationType – constant containing type of current destination (e.g., facebook, google_analytics)
  • toSegment(event) – the function that transforms event to make it compatible with segment data schema (part of Segment Compatibility)
  • toGoogleAnalytics(event), toFacebook(event), toAmplitude(event) – builtin transform functions for corresponding destinations. In the UI version of Jitsu enabled by default for new destinations setup.

Improved Code Debugger

As you may already notice on the screenshot above, we have significantly improved our Code Debugger UX. It now enables code completion based on loaded event data. It is the only instrument you need to write and debug transformation code for your data.

Learn More

  • Read more in the documentation.
  • Follow us on Twitter to get updates on further expansions of Javascript support.
  • Follow & star Jitsu on GitHub
  • Try a cloud version of Jitsu. It's free for up to 250,000 events per month
  • Join our Slack! Our community will help you with any questions!

About Jitsu

Jitsu is an open-source data integration platform offering features like pulling data from APIs, streaming event-base data to DBs, multiplexing and many others.
© Jitsu Labs, Inc

2261 Market Street #4109
San Francisco, CA 94114