What are Derived Columns?

Derived columns are a way to pre-process data from your data feed that can then be used in the keyword and templates. They are created as new virtual columns based on your data feed. For example, if you want to use the 'Brand' column in the ad template but need to capitalize the first alphabet, you can add a derived column for that. 

How are they created and used?
Derived columns are very versatile and can do very complex data processing because they use C# code. You can add a Derived Column on the external source tab in the Campaign Automator. It creates a new column that can be used just like other columns in the feed. This does not edit the existing columns in your feed.

After clicking on 'Add Derived Column', you can give it a name and write the C# code in the box under the name.

If you don't access to a developer, you can ask our team to set them up for you as part of the setup process on the paid subscription plans for Campaign Automator. We've listed some common use cases for Derived Columns below that can be used with minor changes.

Examples of Derived Columns

  1. Remove special characters - This will remove special characters from the words. Put the column name you want to pre process data for instead of <insert column name from feed>. Replace special characters with the ones you want to check for. Code to put in the derived column field
    var value = sourceHeaders["insert column name from feed"];
    value = value.Replace(".", "");
    value = value.Replace("·","");
    value = value.Replace("#","");
    value = value.Replace("!"," ");
    return value;
  2. Truncate columns to have fewer words - This will remove extra words from a column field. The int wordsToRemove = <number> line removes those many words from the end of the phrase in the column and the  int minWordsInOutput = <number> lines leaves a minimum of those many words in the column. For example, if the value in the product title column is "Black and White Shoes For Sale Today" then the below code will create a derived column that will have the value "Black and White Shoes". Put the column name you want to pre process data for instead of <insert column name from feed>

    Code to put in the derived column field

    var value = sourceHeaders["insert column name from feed"];

            int wordsToRemove = 3;

            int minWordsInOutput = 2;

            var x = value.Trim().Split(new char[]{' '}, System.StringSplitOptions.RemoveEmptyEntries);

            var length = x.Length;

            var required = System.Math.Max(minWordsInOutput, length - wordsToRemove);

            if (x.Length > required)

            {

                System.Array.Resize(ref x, required);

            }

            value = System.String.Join(" ", x);

            return value;

Did this answer your question?