metaaddfield
Add a column to the data extract containing selected data from the metaheader.
This guide explains how to configure the metaaddfield instruction. To learn about another instruction, go back to the Available custom script instructions overview.
Introduction
Use the metaaddfield instruction to add a metadata from a data extract into the rows of your data extract table.
Creating a custom script transformation using the metaaddfield instruction
To create and configure a custom script using the metaaddfield instruction, follow these steps:
-
In the Configuration step, select the metaaddfield instruction.
-
To configure the custom script instruction, fill in the required fields below, as well as any optional fields you require:
-
Field name (required)
-
Specify the name of the new column to add to the data extract.
-
Meta name (required)
-
Enter the name of the source field in the header that contains the metadata to add to the data extract. If the metadata is nested in a dictionary, you can navigate to the values using
.
separated field names. An example of navigating nested values is shown in Example 2. -
Index (required)
-
Specify where to add the new column in the data extract. To add the column to the first position, specify 0. To add the column to the last position, specify -1.
-
Subtable
-
Enter the name for a subtable that you want to use within this custom script.
A subtable is a temporary table that only exists for this custom script. You can apply additional instructions within the same custom script to the subtable. However, the subtable cannot be used in any other custom scripts.
If a subtable does not exist for the current custom script, the transformation is applied to the data extract, and the enriched data is output into the subtable. If the subtable already exists for the custom script, the subtable is used as the input for the transformation and optionally as the output.
Example 1
This example is searching for the simple, non-nested metadata of datastream_extract_id
.
Transformation configuration
-
Fieldname*
-
Metadata
-
Metaname
-
datastream_extract_id
-
Index
-
2
Data table before transformation
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
media |
7 |
Brand |
ecommerce |
3 |
Dashboard |
media|social |
18 |
Data table after transformation
Campaign |
Ad Group |
Metadata |
Clicks |
---|---|---|---|
Brand |
media |
1234 |
7 |
Brand |
ecommerce |
1234 |
3 |
Dashboard |
media|social |
1234 |
18 |
Example 2
This example is searching for the nested metadata {"custom_meta_information":{"source_directory":"uploads"}}
.
Transformation configuration
-
Fieldname*
-
Metadata
-
Metaname
-
custom_meta_information.source_directory
-
Index
-
2
Data table before transformation
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
media |
7 |
Brand |
ecommerce |
3 |
Dashboard |
media|social |
18 |
Data table after transformation
Campaign |
Ad Group |
Metadata |
Clicks |
---|---|---|---|
Brand |
media |
uploads |
7 |
Brand |
ecommerce |
uploads |
3 |
Dashboard |
media|social |
uploads |
18 |