preamble
Add a new header and additional rows to a data extract.
This guide explains how to configure the preamble instruction. To learn about another instruction, go back to the Available custom script instructions overview.
Introduction
Use the preamble instruction to add a new header to your data extract. You can also add new rows beneath the new header. The existing header is moved down the data extract and becomes a new row.
Enter the new headers in the order in which they will be displayed. You can skip a column header by entering a blank field (as shown in the example below).
If you add in a new row, ensure the number of fields matches the number of new headers.
Creating a custom script transformation using the preamble instruction
To create and configure a custom script using the preamble instruction, follow these steps:
-
In the Instructions step, select the preamble instruction.
-
To configure the custom script instruction, fill in the following fields. Required fields are marked with an asterisk (*).
-
Fields*
-
Click Add and enter the name of the new header to add. The order of the new header fields is the order in which they are added to the data extract. To leave a header field empty, leave the text field empty.
-
To add in a new row beneath the header, click Add, beneath the cross and enter the name of the value to add under the header. The image in the example configuration shows how to add a header and new row.
-
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
Transformation configuration
In this example, we want to add a new header containing new header fields for columns 1 and 3, while leaving the header for column 2 blank. We also want to add a new row under the header. You can see in the final table that the existing header has been moved down in the data extract.
-
Fields*
Data table before transformation
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
media |
7 |
Brand |
ecommerce |
3 |
Dashboard |
media |
18 |
Data table after transformation
Campaign Name |
|
Number of Clicks |
---|---|---|
Spring Collection |
TikTok Ads |
165 |
Campaign |
Ad Group |
Clicks |
Brand |
media |
7 |
Brand |
ecommerce |
3 |
Dashboard |
media |
18 |