Rename Keys

Rename Keys action changes the name of a source key to a destination key.

The Rename Keys action changes the name of a source key to a destination key. When applied to your processing rule, the Rename Keys action will change the name of a specified key in every occurrence of a source record, to a destination key.

For example, given the following sample website log data.

{"timestamp":"2023-03-28T09:08:41.64283645Z","user_id":3,"page_id":30,"action":"purchase"}
{"timestamp":"2023-03-28T09:08:42.643343109Z","user_id":4,"page_id":10,"action":"purchase"}
{"timestamp":"2023-03-28T09:08:48.643600498Z","user_id":1,"page_id":50,"action":"click"}
{"timestamp":"2023-03-28T09:08:50.643773688Z","user_id":5,"page_id":40,"action":"purchase"}
{"timestamp":"2023-03-28T09:08:51.643932272Z","user_id":1,"page_id":30,"action":"purchase"}
{"timestamp":"2023-03-28T09:08:56.644080944Z","user_id":2,"page_id":40,"action":"click"}
{"timestamp":"2023-03-28T09:09:03.64425954Z","user_id":3,"page_id":30,"action":"click"}
{"timestamp":"2023-03-28T09:09:03.644317046Z","user_id":1,"page_id":20,"action":"view"}
{"timestamp":"2023-03-28T09:09:10.64447719Z","user_id":2,"page_id":50,"action":"purchase"}
{"timestamp":"2023-03-28T09:09:17.644810963Z","user_id":2,"page_id":10,"action":"view"}
{"timestamp":"2023-03-28T09:09:20.644994805Z","user_id":1,"page_id":50,"action":"view"}

To change the name of the “user_id” key to “customer_id” , from the actions drop-down menu of your processing rules tab, select `Rename Keys”. In your Source Key input box, add the key “user_id” and in the destination key input box, add “customer_id”. Then click Apply.

\

Your processing rule will now move all the user_id values to the customer_id key.

When Regex Mode is selected all keys that match the regex will be moved to new keys defined by the substitution pattern, which can reference captures in the regex. To move all keys with the pattern “us” to “cus”, from the actions drop-down menu of your processing rules tab, select `Rename Keys”. In your Source Key input box, add the key “user_id” and in the destination key input box, add “customer_id”, check the “Regex Mode” box then click Apply.

All keys with the “us” pattern will now be moved to a new key with the “us” pattern replaced with “cus” in its name.

Last updated