Skip to content
Amey Varangaonkar edited this page May 29, 2020 · 7 revisions

Welcome to the wiki page of the Sample User Transformation repository!

This page is designed to include detailed information on the sample user transformations included in this repository.

Quick Overview of User Transformations

User Transformations is a unique feature offered by RudderStack that allows you to code custom functions to transform your events, as per your use-case or requirement.

The following user transformations are included in this repository:

User Transformation for PII Detection and Masking

This transformation takes developer-supplied attribute names along with the values of matching attributes, and replaces them with Xs or a masked representation, as per the developer's choice.

Read more on how you can implement this function for your apps.

User Transformation for Selective Event Removal and Value Aggregation

If an enterprise generates a large volume of events, but the target analytics destination charges by volume - then only certain samples of event data can be sent to the destination for analytics. This transformation function allows you to:

  • Selectively removes events based on a name match
  • Selectively removes events based on the value of a given attribute
  • Aggregates values of certain attributes for multiple instances of a specific type of event in a batch and then replaces those instances with a single instance containing the aggregated attributes

User Transformation for Missing Value Substitution and Batch Size Reduction or Sampling

This user transformation does the following:

  • Replaces missing values for a User-Agent attribute
  • In cases where the developer has populated crucial attributes within nested structures but not at the root level, copies the values to the root level
  • Reduces batch size and then selects only a subset of events

User Transformation for Removing Attributes without Values

In this transformation, all the attributes within a given event payload which do not have any value are removed to reduce the payload size and optimize the storage space for warehouses.

User Transformation for Filtering by Email Domain, Name Splitting, and Campaign Parameter Extraction

This user transformation does the following:

  • Filters out events triggered by users whose email address, if present, is from a particular domain. This can help in filtering out events triggered by users belonging to the enterprise owning the installation. Such users would not really be customers per se, and hence might not be of interest
  • If Full Name has been specified for the user, then splits the same into first and last names
  • In case of web events, if the URL of the page visited contains UTM information, then the same is extracted and appropriate keys of the canonical object model are populated. These can then be used by subsequent campaign-oriented Destination Transformers, e.g. MailChimp

User Transformation for Data Enrichment using Clearbit APIs

This transformation is useful for enriching the user data by invoking the Clearbit API and embedding the results within events. In this sample, the Person API of Clearbit is invoked using the e-mail address of the user.

User Transformation for Enriching Event Using IP2Location

Enrich event data by invoking the IP2Location API and adding the location information corresponding to the event

User Transformation for Adding Device, OS and Browser Info to an Event

This transformation does the following:

  • Extracts the client-side device, OS and browser names and versions by parsing a User-Agent string present in the event payload
  • Adds the above information as JSON structure to the event payload

Note: These transformations can be used as-is, or tweaked depending on your use-case or requirement

Resources

Here you can find some useful links related to creating and using your own user transformations in RudderStack.