SVG
Log inTry for free

Endless applications for RudderStack Transformations

Blog Banner

With Transformations, you can transform your event data in flight using custom Javascript or Python functions. Transformations is one of our most widely used features – over 75% of our customers use them. Customers love them because they deliver ultimate flexibility and allow you to adapt to changes fast.

Because of their inherent flexibility, you can use Transformations for a wide range of use cases. The challenge lies in identifying all of the different ways you can apply them to solve more problems.

In this piece, I’ll outline a number of use cases to help you understand all of the different ways you might use transformations to deliver more value with your data.

"Transformations are one of RudderStack’s core differentiators. While most readily considered a tool for simple formatting, they enable much more. With the power of transformations, you can orchestrate complex actions such as real-time personalizations and FinOps management within downstream tools. The expansive scope of possibilities within transformations help make RudderStack more than just a product but a truly developer-friendly innovation.”

Badri Veeraragavan, Product Director at RudderStack

Endless possibility

To understand all the different ways you can leverage Transformations, it’s helpful to group use cases into a few broad categories:

  • Data formatting and cleaning
  • Advanced use cases
  • Niche use cases

I’ll go through each of these categories, providing specific examples of how and why you might use Transformations at your business.

Standard use cases: Data cleaning and data formatting

Data cleaning and formatting use cases are the bread and butter of Transformations. They’re used by the majority of our customers, and while they only scratch the surface when it comes to all you can do with the tool, they drive a lot of value. These use cases enable you to seamlessly send good-quality data without PII to end destinations. Here are a few of the most common standard use cases with some available examples included:

  • Data cleaning: Transformations enable you to easily clean your data before it reaches its destination by removing or renaming event fields. (samples on Github)
JAVASCRIPT
export function transformEvent(event) {
if (event.properties) {
const keys = Object.keys(event.properties);
if (keys) {
keys.forEach(key => {
if (event.properties[key] === null) delete event.properties[key];
})
}
}
return event;
}
  • Data filtering: You can filter events using allowlist or denylists to drop unwanted events and ensure only relevant, necessary data reaches the destination. (samples on Github)
JAVASCRIPT
export function transformEvent(event, metadata) {
const eventNames = ["game_load_time", "lobby_fps"];
const eventName = event.event;
if (eventName && eventNames.includes(eventName)) return;
return event;
}
  • Data formatting and aggregation: Transform certain parts of the payload or reformat it to meet destination requirements. For some more complex use cases, you can send the entire payload as a single JSON payload. You can even send a single atomic table to your warehouse to enable a data analyst to query a single table instead of having to join multiple tables.
  • Data enrichment: Automatically add additional data to your events from internal or external APIs. You can hit the Clearbit API to enrich events with third-party data like location, employment, and social media details. Another example here is hitting an IP-to-geolocation API so you can easily query your events based on the geolocation data. (samples on Github)
JAVASCRIPT
export async function transformEvent(event) {
const email = event.context?.traits?.email;
if (email) {
const res = await fetch("https://person.clearbit.com/v2/combined/find?email=" + email, {
headers: {
"Authorization": "Bearer <your_clearbit_secure_key"
}
});
event.context.traits.enrichmentInfo = res;
}
return event;
}
  • Data quality: In situations where using tracking plan rules could lead to dropped events, you can use transformations to ensure data quality. You can also use a tracking plan to identify violations and have transformations act on those violations. For example, a transformation can trigger an event in a downstream tool that alerts the engineering of an unplanned event violation so they can update instrumentation to eliminate the violations.
  • Data privacy: Replace or mask any sensitive data in your payloads on a per-destination basis to protect sensitive information and ensure compliance. (samples on Github)
JAVASCRIPT
import { walk } from "fuzzyFindReplace";
export function transformEvent(event, metadata) {
const targetKeys = [
"SSN",
"Social Security Number",
"social security no.",
"social sec num",
"ssnum"
];
walk(event, targetKeys, "XXX-XX-XXXX");
return event;
}

For more details on these common use cases, check out the Transformations overview article in our knowledge base.

Advanced use cases: Beyond the basics

Transformations aren’t just a tool for basic data cleaning and formatting. You can use them to solve trickier problems and unlock innovation. Here are some of the more advanced ways you can apply transformations:

  • Real-time activations: You can use Transformations to trigger push notifications in real time based on event type. For customer engagement, you might trigger a notification to Braze when certain payload conditions are met to automatically send out customer communications. You can also trigger synthetic events based on activity. For example, when a first-time user logs in, you can trigger an event to send their information to Salesforce.
  • Generating synthetic events: Transformations can generate conversion events upon specified conversion activities and send them downstream, this is especially useful for ad platforms.
  • Real-time experience personalization: Using Transformations + Redis, you can create personalized experiences for your customers. Store key user IDs and personalized experiences in Redis, then use the Transformations API to check Redis when a user visits your site/app, if there’s a match, you can serve the personalized experience using a fetch call from transformations.
  • Event Filtering and Sampling for SaaS cost management: To reduce unnecessary costs in your destination apps you can use Transformations to filter unwanted or redundant events. This is particularly useful when a source is connected to multiple destinations and certain events are important for some destinations but unnecessary and expensive in others. Instead of changing the instrumentation and losing data, you can use transformations to filter out events from specific destinations.
  • Filter Bot traffic: To reduce noise from bot traffic, you can use transformations to identify bots by checking an event's user agent against a modified list of known bot user agents from the crawler-user-agents.json (samples on Github)

Niche use cases: An endless long tail

So far we’ve covered basic and advanced use cases that are more broadly relevant. Transformations, though, are also well suited to solve niche problems that might be unique to your business. Here are a few examples of how you can use Transformations for specific challenges:

  • Webhook-specific improvements: Transformations can dynamically set headers or append URLs before delivering events to your webhook destinations. This allows you to identify the events and send them to different paths that you set using Transformations. For example, you might send identify events to /users and group events to /organizations.
  • Sending events to custom destinations: With transformations, you can send events to custom destinations by routing the events using a webhook. This allows you to easily send events to destinations that aren’t included in our integration library.

Do more with Transformations

The power of Transformations is limitless. You can use them to implement a wide range of use cases to quickly solve problems and unlock innovation. Read our docs on Transformations and the Transformations API for more details. To get started quickly, you can use the Transformation templates available in our app or visit our Github repo with sample transformations. Have an interesting use case? Join us on Slack to share.

Unlock more value with RudderStack Transformations

Sign up for RudderStack today to see the power of Transformations for yourself

December 22, 2023
Badri Veeraragavan

Badri Veeraragavan

Director of Product