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 enrichment using the metaaddfield instruction
To create and configure a custom script using the metaaddfield instruction, follow these steps:
-
In the Instructions 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 enrichment 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 enrichment and optionally as the output.
Example 1
This example is searching for the simple, non-nested metadata of client_name
.
Enrichment configuration
-
Fieldname*
-
Metadata
-
Metaname
-
client_name
-
Index
-
2
Data table before enrichment
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
media |
7 |
Brand |
ecommerce |
3 |
Dashboard |
media|social |
18 |
Data table after enrichment
Campaign |
Ad Group |
Metadata |
Clicks |
---|---|---|---|
Brand |
media |
Tenant#1 |
7 |
Brand |
ecommerce |
Tenant#2 |
3 |
Dashboard |
media|social |
Tenant#3 |
18 |
Example 2
This example is searching for the nested metadata {"custom_meta_information":{"source_directory":"uploads"}}
.
Enrichment configuration
-
Fieldname*
-
Metadata
-
Metaname
-
custom_meta_information.source_directory
-
Index
-
2
Data table before enrichment
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
media |
7 |
Brand |
ecommerce |
3 |
Dashboard |
media|social |
18 |
Data table after enrichment
Campaign |
Ad Group |
Metadata |
Clicks |
---|---|---|---|
Brand |
media |
uploads |
7 |
Brand |
ecommerce |
uploads |
3 |
Dashboard |
media|social |
uploads |
18 |