namingconvention

Add new columns to the data extract by using parts of the values from an existing field.

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

Introduction

Use the namingconvention instruction to add new columns to the data extract by using parts of the values from an existing column. Use a regular expression to identify which parts of the value to add to a new column. This instruction is a simplified version of the capture instruction.

An error is raised if a match is not found for the regular expression and the enrichment is stopped. This instruction does not keep the original values.

The Smart Naming Convention standard enrichment enables you to detect naming conventions and transform your data extract in a few easy steps, instead of using a custom script. For more information, see Smart Naming Convention.

Creating a custom script enrichment using the namingconvention instruction

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

  1. Create a custom script enrichment.

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

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

Field*

Select the column that contains the original values from which to create new values. Choose from one of the following options:

  • String - Select String to enter the name of the column that contains the original values.

  • Integer - Select Integer to enter the position of the column that contains the original values in the data extract.

    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.

Pattern*

Enter a regular expression with a number of capturing groups to match values in the source field.

Newfields*

Specify the names of the new fields to add to the data extract. Specify a new field for each capturing group specified in the regular expression in Pattern*. A value in a new field is what the corresponding capturing group matches in the source field's value within the same 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 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*

Campaign

Pattern*

(.*)_(.*)

Newfields*

Campaign type

Campaign ID

Data table before enrichment

Campaign

Ad Group

Clicks

Brand_1

media

7

Brand_2

ecommerce

3

Dashboard_1

media

18

Dashboard_B

media|social

5

Data table after enrichment

Ad Group

Clicks

Campaign type

Campaign ID

media

7

Brand

1

ecommerce

3

Brand

2

media

18

Dashboard

1

media|social

5

Dashboard

B