set_meta

Add values to the metadata of a data extract.

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

Introduction

Use the set_meta instruction to add values or update values in the metadata of a data extract. You can add a new node to the metadata and populate it with a value from the data extract or a value of your choice. You can also update an existing node with a value from the data extract or a value of your choice

Creating a custom script enrichment using the set_meta instruction

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

  1. Create a custom script enrichment.

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

  3. To configure the custom script instruction, fill in the following fields. Required fields are marked with an asterisk (*).

Fieldname*

Enter the name for the node to add to the metadata. Choose one of the following options:

  • Enter the name of a new node to add the metadata of the data extract.

  • Enter the name of an existing node in the data extract to update. Enter the name of the existing node exactly as it appears in the metadata.

Sourcefield

Select the name of the column that contains the value to add to the chosen node in the metadata. This column must contain only non-unique values (meaning all the values in the column are the same).

Select a column in one of the following ways:

  • Select String and enter the name of the column.

  • Select Integer and enter the position of the column in the data extract as an index value. Counting starts at 0. To select the first column, enter 0. To select the second column, enter 1. To select the last column in the data extract, enter -1.

If you provide a source field, you cannot enter a value into the Value field.

Value

Enter a value with which to populate the chosen node in the metadata. You can enter either a string or a numerical value. If you provide a value, you cannot use an existing value through the Sourcefield field.

Clear

Select this value to clear all the values currently in the custom_meta_information node.

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

In this example, the set_meta enrichment uses values in the data extract to create a new field in the metadata. These values are taken from the column entered in sourcefield.

Enrichment configuration

Fieldname*

campaign_start_date

Sourcefield*

Campaign Start

Data table used for enrichment

Campaign

Campaign Start

Campaign End

Clicks

Campaign Dates

Kanlam

2022-01-03

2022-01-08

56789

2022-01-03

Kanlam

2022-01-03

2022-01-08

56789

2022-01-04

Kanlam

2022-01-03

2022-01-08

56789

2022-01-05

Kanlam

2022-01-03

2022-01-08

56789

2022-01-06

Kanlam

2022-01-03

2022-01-08

56789

2022-01-07

Result of enrichment

After the enrichment has been applied, the metafield campaign_start_date is added to the data extract metadata and this metafield has a value of 2022-01-03. If there were unique values in the sourcefield column, the enrichment would fail.

Example 2

In this example, the set_meta enrichment uses values defined in the enrichment configuration to create a new field in the metadata.

Enrichment configuration

Fieldname*

campaign_internal_id

Value*

ADV_77648

Result of enrichment

After the enrichment has been applied, the metafield campaign_internal_id is added to the data extract metadata and this metafield has a value of ADV_77648.