# Transformations

## Types of Transformations

Freshpaint supports three uses for transformations

### Standard Mapping

Standard mappings are used to re-format the data you send to Freshpaint into the structure that a destination accepts and assigns special meaning to. For example, you can use transformations to rename your `add_to_cart` event that you're sending to Freshpaint into Facebook or Pinterest's `AddToCart` event.

{% content-ref url="/pages/-MKZtVkSgtrloq-sBx6v" %}
[Standard Events](/admin-panel/transformations/standard-events.md)
{% endcontent-ref %}

### Modify Data

You can use transformations to modify the data Freshpaint sends to destinations in order to match historical data or remove sensitive information before they are sent to a destination.&#x20;

{% content-ref url="/pages/-MK\_38SQziuKN592reIF" %}
[Modify Data](/admin-panel/transformations/fix-bad-data.md)
{% endcontent-ref %}

### Modify User Data

Identify transformations allow you to re-format OR modify the user data you send to Freshpaint. This can be particularly useful if a certain destination requires a user property in one format, and another destination requires that same user property in a different format.&#x20;

For example, if one destination enforces a naming convention that the user's operating system must be sent as `user_os` while another destination requires the operating system to be sent as `os`, you can rename the user property accordingly *before* the identify event is sent to the destination.

{% content-ref url="/pages/biMdtAzPh3uk2IhgxIlF" %}
[Modify User Data](/admin-panel/transformations/modify-user-data.md)
{% endcontent-ref %}

{% hint style="info" %}
SQL transformations do not apply to identify events at this time.
{% endhint %}

## Supported Operations

{% tabs %}
{% tab title="Rename Event" %}
Use this operation to rename the event. For example, if you have an event named `order_complete`, but you want this to be named `OrderCompleted` in a destination, you can use this operation.

{% hint style="warning" %}
You can only rename an event once. If you try to add two "Rename Event" operations to a given event + destination combination, you will receive an error.
{% endhint %}
{% endtab %}

{% tab title="Rename Property" %}
Use this operation to rename a property. This is often used to fix typos without involving developers, or for fixing data to match historical data.&#x20;

### Example use cases:

Rename a property with a typo like `referer` to `referrer`

Rename the property `cart_total` to `revenue`
{% endtab %}

{% tab title="Change Property Type" %}
Use this operation to convert between text, number, and true/false values of a property.

If a value cannot be converted to the desired type, it is left untouched.

### Convert To Number

When converting a property into a number, we leave everything that is not text untouched. For text, we attempt to parse it as a decimal value, if it has characters that are non-numeric, it fails.&#x20;

| Initial Value    | Initial Type | Result Value     | Result Type |
| ---------------- | ------------ | ---------------- | ----------- |
| `"-1"`           | Text         | `-1`             | Number      |
| `"24.6"`         | Text         | `24.6`           | Number      |
| `"$812.37"`      | Text         | `"$812.37"`      | Text        |
| `1`              | Number       | `1`              | Number      |
| `null`           | Null         | `null`           | Null        |
| `"button"`       | Text         | `"button"`       | Text        |
| `"$fourty-five"` | Text         | `"$fourty-five"` | Text        |

### Convert To Text

When converting a property's value to text, we leave null and text values as-is, but convert objects, arrays, numbers and true/false values. For objects and arrays, we json-encode them without modifying the sub-element's types. For numbers and true/false values, we simply convert them to text as you'd expect.

| Initial Value            | Initial Type | Result Value               | Result Type           |
| ------------------------ | ------------ | -------------------------- | --------------------- |
| `true`                   | True/False   | `"true"`                   | Text                  |
| `1`                      | Number       | `"1"`                      | Text                  |
| `null`                   | Null         | `null`                     | Null                  |
| `"button"`               | Text         | `"button"`                 | Text                  |
| `{x: 'yes', y: 23}`      | Object       | `'{"x": "yes", "y": 23}'`  | Text *(json-encoded)* |
| `[1, 2, 3, "no", false]` | Array        | `"[1, 2, 3, 'no', false]"` | *Text (json-encode)*  |

### Convert To True/False

When converting a property's value to True/False, all values besides the text values `t`, `f`, `true` and `false` (case insensitive) are let as-is.&#x20;

{% hint style="warning" %}
Note: the numerical values of `0` and `1` are not converted to `false` or `true`
{% endhint %}

| Initial Value | Initial Type | Result Value | Result Type |
| ------------- | ------------ | ------------ | ----------- |
| `'t'`         | Text         | `true`       | True/False  |
| `'f'`         | Text         | `false`      | True/False  |
| `'x'`         | Text         | `'x'`        | Text        |
| `'TrUe'`      | Text         | `true`       | True/False  |
| `'fAlse'`     | Text         | `false`      | True/False  |
| `'truthful'`  | Text         | `'truthful'` | Text        |
| `true`        | True/False   | `true`       | True/False  |
| `false`       | True/False   | `false`      | True/False  |
| `0`           | Number       | `0`          | Number      |
| `42`          | Number       | `42`         | Number      |
| {% endtab %}  |              |              |             |

{% tab title="Uppercase/Lowercase Property" %}
Use these operations to convert the value of a property to upper or lower case. Useful for normalizing email addresses, or converting a `currency` property from `usd` to `USD` to match historical data.
{% endtab %}

{% tab title="Delete Property" %}
Use this operation to delete an event property. This is often useful if you want to remove sensitive data from flowing into a third party destination.
{% endtab %}

{% tab title="Send Built-in Property" %}
Use this operation to send the built-in properties to destinations that Freshpaint automatically captures for each event.

The following built-in properties are currently supported:

| Builtin Property Name    | Remarks                                                                                          | Example Value                                                |
| ------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| Time                     | [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time) when the event was captured            | `1660750813.235`                                             |
| Device ID                |                                                                                                  |                                                              |
| User ID                  | Identifier for the user. Can be a UUID if the user is anonymous, or the user email if logged in. | <support@freshpaint.io>                                      |
| OS                       | Operating System                                                                                 | Mac OS X                                                     |
| Browser                  |                                                                                                  | Chrome                                                       |
| Browser Version          |                                                                                                  | `104`                                                        |
| Current URL              | Full url of the page on which the event was captured.                                            | <https://yourwebsite.com/pages/target-page.html?param=value> |
| Host                     | Domain of the page on which the event was captured.                                              | yourwebsite.com                                              |
| Initial Referrer         |                                                                                                  |                                                              |
| Initial Referring Domain |                                                                                                  |                                                              |
| IP                       | The user's IP Address                                                                            |                                                              |
| Pathname                 |                                                                                                  | /pages/target-page.html                                      |
| Referrer                 |                                                                                                  |                                                              |
| Referring Domain         |                                                                                                  |                                                              |
| Screen Height            | Screen height in pixels                                                                          | `1080`                                                       |
| Screen Width             | Screen width in pixels                                                                           | `1920`                                                       |
| UTM Source               |                                                                                                  |                                                              |
| UTM Medium               |                                                                                                  |                                                              |
| UTM Campaign             |                                                                                                  |                                                              |
| UTM Content              |                                                                                                  |                                                              |
| UTM Term                 |                                                                                                  |                                                              |
| Pageview ID              |                                                                                                  |                                                              |
| Session ID               |                                                                                                  |                                                              |
| Target Text              | Text of the element which was clicked on                                                         | button text                                                  |
| Href                     | The href of a link which was clicked on                                                          | yourhref.com                                                 |

You can also see the built-in properties that captures in [liveview](https://app.freshpaint.io/events/liveview).&#x20;

<figure><img src="/files/1oZnIm7DWTNGbzuLFoNC" alt=""><figcaption><p>View Built-in properties for each event in Live View</p></figcaption></figure>
{% endtab %}

{% tab title="Send Constant Property" %}
Use this operation to send some constant value as a property. You can use one of the following values:

* Number, which support numeric values (42, 42.1, 0.123)
* True/False, which supports only `True` or `False` as literal booleans
* Text, which can be any text
  {% endtab %}
  {% endtabs %}

## Transformations Dashboard

From the transformation dashboard, you can view and edit your existing transformations, as well as launch the wizard to guide you through creating a new transformation.

Transformations are grouped into sets based on their Transformation Type, Freshpaint Event and Destination.

### Creating a new transformation

You can launch the wizard to create a new transformation by clicking the button in the top right.

<figure><img src="/files/hGo0J2SmdnvDfqmopRRk" alt=""><figcaption></figcaption></figure>

### Add a new operation to a transformation

1. Expand the transformation set you want to modify by clicking on it. If you just created a new transformation via the wizard, it will already be opened.

![Expanding a transformation set](/files/-MK_FcJshOoaburzF_6R)

2\. Click the + button and choose the operation you want to apply. See [above](/admin-panel/transformations.md#supported-operations) for operation descriptions.

<figure><img src="/files/5Xc7nGEHcuflXYDqKR8d" alt=""><figcaption></figcaption></figure>

### Deleting or modifying an operation

1. Expand the transformation set that contains the operation you want to modify by clicking on it. If you just created a new transformation via the wizard, it will already be opened.
2. Click on the operation you want to delete or modify. It will highlight and show a pencil icon as you hover over it.
3. From here you can either change the attributes and click "Save" or delete the operation by clicking "delete."

![](/files/-MK_uze0cxJeust7fqi-)

### Deleting an entire transformation set

You can delete an entire set of transformations by clicking on the trash icon on the right side of any transformation set.

<figure><img src="/files/TGCM1bzUvYx74LA6uP76" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.freshpaint.io/admin-panel/transformations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
