# Track data shape

## Introduction

The `track data` shape is used to track processed data, based on field paths that you define. When data passes through a `track data` shape, the values associated with your defined field paths are tracked - which means they can be [reviewed from the tracked data page](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/track-data-shape/the-tracked-data-page).&#x20;

For example, you might want to track all `customer_id` values that pass through a flow, so at any time you can quickly check if/when/how a given customer record has been processed.

{% hint style="info" %}
A single incoming payload for [any process flow shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes) should not exceed 500MB.

We recommend processing multiple, smaller payloads rather than one single payload (1000 x 0.5MB payloads are more efficient than 1 x 500MB payload!).

For payloads up to 500MB, consider adding a[ flow control shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape) to batch data into multiple, smaller payloads. Payloads exceeding 500MB should be batched at source.
{% endhint %}

## Need to know

* By default, tracked data is [available for viewing](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/track-data-shape/the-tracked-data-page) for 15 days after it was last tracked. This can be increased up to 90 days; please [contact our Sales team](https://www.wearepatchworks.com/pages/contact-us) if you'd like to extend your retention period.
* Data to be tracked can be a maximum of 255 characters (tracked data is typically a specific payload field - for example, a customer ID).
* The track data shape works with incoming payloads from a [connection shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape), a [manual payload](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/manual-payload-shape), an [API request](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/broken-reference), or a [webhook](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/trigger-shape/trigger-shape-webhook).
* [Payload](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/manual-payload-shape), [flow](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-versioning), and [metadata](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/metadata-variables) variables are supported when defining success messages.
* JSON payloads are supported.&#x20;

## Adding & configuring a track data shape

You can add as many `track data` shapes to a process flow as required. For example, you might place one immediately after a *receiving* connector to track everything received before anything else happens to the data, and another after the final *sending* connector to track everything sent into your destination system.

To add and configure a new `track data` shape, follow the steps below.

**Step 1**\
In your process flow, add the `track data` shape in the usual way:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FdZH3fbkeoghk3xpUxDZk%2Fadd%20tracked%20data%201.png?alt=media&#x26;token=13ba5995-b603-454a-8a15-2c63b4dd0d2c" alt="" width="375"><figcaption></figcaption></figure></div>

**Step 2**\
Configure settings as required - the table below summarises available fields:

| Field                                      | Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>Source instance <br>Source endpoint</p> | If data is coming into the process flow via a [connector shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape), use these dropdown fields to select appropriate source connector details (i.e. the same instance and endpoint as configured for the previous connector shape). If data is coming into the flow via a non-connector source (such as a [manual payload](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/manual-payload-shape), [API request](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/broken-reference), or [webhook](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/trigger-shape/trigger-shape-webhook)) then leave these fields blank.                                                                                                                                                                                                                                                                                                                                |
| Entity                                     | <p>If data is coming into the flow via a <a href="connector-shape">connector shape</a>, this field will be set as required by default. Otherwise, select the entity type associated with the data field(s) that you want to track. </p><p></p><p>Note that the selection made here has no impact on how the shape performs - it simply determines how the tracked field is categorised on the <a href="track-data-shape/the-tracked-data-page">tracked data page</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Direction                                  | <p>If data is received via a <a href="connector-shape">connector shape</a>, this field will be set as required by default. Otherwise, select the flow direction (<code>send</code> or <code>receive</code>) associated with the data field(s) that you want to track:</p><ul><li>If the tracked data is being pulled from a source, set this option to <code>receive</code></li><li>If the tracked data is being pushed to a destination, set this option to <code>send</code></li></ul><p>Note that the selection made here has no impact on how the shape performs - it simply determines how the tracked field is categorised on the <a href="track-data-shape/the-tracked-data-page">tracked data page</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| Field paths                                | <p>Define one or more data fields to be tracked - i.e. fields that you may want to look up in the event of a query.</p><p></p><p>If multiple fields are specified, these values are tracked as one, concatenated value. To track multiple fields separately, use one shape per field.</p><p></p><p>If data is received via a <a href="connector-shape">connector shape</a>, you can navigate the associated data structure to select a field for tracking - for example:<br><br><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FBwV5LiWugjDzOxQUv8wM%2Fadd%20tracked%20data%203.png?alt=media&#x26;token=ad845fbf-caea-47a5-8edb-7a060ff9c5ff" alt=""><br><br>If data is received via a non-connector source (such as a <a href="manual-payload-shape">manual payload</a>, <a href="broken-reference">API request</a>, or <a href="trigger-shape/trigger-shape-webhook">webhook</a>),  enter a path to the required field manually. <br><br>If you need to track meta or flow variables, toggle the <code>use custom value</code> option to <code>on</code> and enter the correct <a href="../../dynamic-variables">variable syntax</a>. For more information on this option, please see the <a href="#custom-values">custom values</a> section below.</p> |

**Step 3**\
Save and then re-access settings for this shape. For example: &#x20;

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F49OxKz0GFCn90aNfpXyK%2Fadd%20tracked%20data%207.png?alt=media&#x26;token=fa6ffa9f-3955-40b6-8678-ffaa0c6c8b2f" alt="" width="357"><figcaption></figcaption></figure></div>

Now you'll w see `success criteria` options at the bottom of the shape settings drawer:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FHxX2hDOEQ9MRfygAjtGo%2Fadd%20tracked%20data%208.png?alt=media&#x26;token=aedeaba4-2ac3-43a2-9b1a-4b6fdbe318df" alt="" width="375"><figcaption></figcaption></figure></div>

**Step 4**\
The `success criteria` options are optional. If you don't need to apply these, then your setup is complete - close the settings drawer and continue with your process flow as required. If you do want to use these options, see below for guidance.

### Success criteria options

When data passes through a `track data` shape, specified data fields are tracked, and by default, tracked data is marked as a `success`. &#x20;

However, there may be times when you want to control the conditions under which the status of tracked data is deemed a `success` or a `failure`*,* and to record this outcome for future reference.  The `success criteria` section allows you to:

* Define filter conditions that must be met for an entity's progress to be reported as a `success` or `failure` on the [tracked data page](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/track-data-shape/the-tracked-data-page).
* Add a message to be displayed on the [tracked data page](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/track-data-shape/the-tracked-data-page) for this tracked item.

{% hint style="info" %}
When tracked data is marked as `failed`, it is still tracked and the shape still processes successfully - for example:

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FSf2foSULJMCNL7K0Nhmx%2Ftrack%20failure%20%202.png?alt=media\&token=82c30d24-d2e3-43b1-9f78-e942f1f3b8fc)

In this run log, notice that the tracked data is marked as a `failure` (1) but tracked data is stored (2), and the track data step succeeds (3).

In this context, tracked data marked as a `failure` simply means that one or more filters defined for success were not matched, and therefore, this item is reported as a `failure`.
{% endhint %}

#### Success criteria filters

Any conditions that you want to apply can be added via filters. To define a new filter, click the `add filter` button:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FBFw0dbM2IMlaZBXfX4zp%2Fadd%20tracked%20data%209.png?alt=media&#x26;token=0139b0db-1f05-49b6-8ff3-9c4d888a58dd" alt="" width="375"><figcaption></figcaption></figure></div>

These filters work the same as [other filters](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/filter-shape) in the dashboard - select/define a field, then set conditions and values.&#x20;

You can add as many filters as you need - multiple filters work together with an 'AND' operator. Remember that you're defining conditions that must be met for a `success` outcome - if multiple filters are present, they must ALL be matched. If one or more filters are not matched, the associated tracked data is marked as a `failure`.

{% hint style="info" %}
Filters can be based on any field(s) found in your data, irrespective of whether you chose to track them.
{% endhint %}

The success or failure outcome from these filters is reported in the logs, and also on the [tracked data page](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/track-data-shape/the-tracked-data-page).&#x20;

#### Success criteria message

You can define a message to be displayed on the [tracked data page](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/track-data-shape/the-tracked-data-page) for the associated tracked data item:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FnEUmFV8oXt5txep0j7dG%2Fadd%20tracked%20data%2010.png?alt=media&#x26;token=901123b6-8200-4fa3-8fee-ef3af9d7e6a3" alt="" width="375"><figcaption></figcaption></figure></div>

This message can be text-only, or any combination of text, [payload variables](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/payload-variables), [flow variables](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables), and [metadata variables](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/metadata-variables). For example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpXeUZzJjXW55V84kJHsz%2Fadd%20tracked%20data%2011.png?alt=media&#x26;token=42de20ab-e4a7-4a71-badc-bcd80d60d31d" alt="" width="375"><figcaption></figcaption></figure></div>

You will find these messages on the [tracked data page](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/track-data-shape/the-tracked-data-page). For example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FRfVlpHrSc5sRbwjAAVNA%2Fsuccess%20example%202.png?alt=media&#x26;token=f9ac4da1-d050-4c7b-8d98-17c2a83f72a1" alt=""><figcaption></figcaption></figure></div>

Messages are added to the [tracked data page](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/track-data-shape/the-tracked-data-page) in any of the following scenarios:

* No success criteria filters are defined
* Success criteria filters are defined, and the outcome is `success`
* Success criteria filters are defined, and the outcome is `failure`

### Custom values

When defining a `field path` to be tracked, a `use custom value` toggle option is available:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FnHxvYGBz3NQyztxdvkwK%2Fcustom%20value%201.png?alt=media&#x26;token=09062554-14aa-4a93-a0aa-edf2da0d1642" alt="" width="353"><figcaption></figcaption></figure></div>

This option can be used for cases where you want to specify a meta or flow variable value to be tracked, but you don't want that value to be taken from incoming payloads.&#x20;

For example, suppose your process flow includes a [set variables shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/set-variables-shape), setting a meta-variable as follows for incoming payloads:

`name` : `filename` \
`value` : `AW25`.

Now, suppose you want to track this meta-variable value. You'd be forgiven for entering meta-variable syntax ( `[[meta.filename]]`) in the `field path`, as below:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FLv1dtWVvvpmlttPnzXWv%2Ftd%20eg%201.png?alt=media&#x26;token=7d44e057-14ee-488f-a2d2-83c57d951069" alt="" width="354"><figcaption></figcaption></figure></div>

However, this would be processed as follows:

1. Resolve `[[meta.filename]]` &#x20;
2. Set the resolved value (`AW25`) as the `field path` key to be tracked &#x20;
3. Look for a key named `AW25` in the incoming payload
4. Fail to find a key named `AW25` in the incoming payload, so nothing is tracked

The correct approach is to toggle the `use custom value` toggle option to `on` and enter meta-variable syntax ( `[[meta.filename]]`) in the `custom value`, as below:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fp7ET1KJ4CxAMmHU1BpHr%2Ftd%20eg%202.png?alt=media&#x26;token=b2aa09f1-fd4c-4b47-9796-56a4a1817f0f" alt="" width="356"><figcaption></figcaption></figure></div>

This will be processed as follows:

1. Resolve `[[meta.filename]]` &#x20;
2. Track the resolved value (`AW25`)&#x20;

## Related pages

* [The tracked data page](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/track-data-shape/the-tracked-data-page)
* [Field tagging & tracked fields](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/endpoint-options/schema-taxonomy/field-tagging#what-are-tracked-fields)
