addfield

Add a new column to the data extract that contains the same value in every row.

This guide explains how to configure the addfield instruction. To learn about another instruction, go back to the Available custom script instructions overview.

Introduction

Use the addfield instruction to add a new column to your data extract and specify a value that this column will contain in every row.

The Create or Edit Columns standard enrichment enables you to add new columns to your data extract in a few easy steps, instead of using a custom script. For more information, see Create or Edit Columns.

Creating a custom script enrichment using the addfield instruction

To create and configure a custom script using the addfield instruction, follow these steps:

  1. Create a custom script enrichment.

  2. In the Instructions step, select the addfield instruction.

  3. 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.

Field 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.

Field value

Specify the value to use in every row of the new column. If you leave this field empty, the new column added to your data extract will be empty.

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

Enrichment configuration

Field Name

Country

Field Value

Austria

Field 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

Country

Clicks

Brand

media

Austria

7

Brand

ecommerce

Austria

3

Dashboard

media|social

Austria

18