- TLC Home Home
- Discussions & Ideas Discussions & Ideas
- Product Guides Product Guides
- Knowledge Base Knowledge Base
- Developer Docs Developer Docs
- Education Education
- Blog Blog
- Support Desk Support Desk
Data transformation functions are invoked after an event is collected from the data source and before the event is processed and can be used for a variety of purposes, including the following:
This article provides details on the TealiumEvent
input parameter, as well as information on the flatten
library. For examples of data transformation functions, see Functions Example Code.
In this article:
The following tables provide information on the TealiumEvent
properties and data types.
Property | Type | Description |
---|---|---|
account |
string | Read-only. Account information. |
client_ip |
string | Read-only. Client IP address. |
data |
EventData | Read-only. See EventData Data Type. |
dataSourcePlatform |
string | Read-only. Name of the data source platform. See dataSourcePlatform Values. |
enrichmentOnly |
Boolean | Read-only. Always false for live events. If false DataAccess is enabled, the event can be sent to DataAccess. May be true for bulk import events (event.type equals "BULK_IMPORT"). If true, event data can be used only for enrichment. |
env |
string | Read-only. Specifies the execution environment (dev or prod). |
event_id |
string | Read-only. Event ID. |
new_visitor |
Boolean | Read-only. True if this is the first visit for the user, otherwise false. |
page_url |
EventUrl | Read-only. Omitted for mobile events. See EventURL Data Type. |
post_time |
number | Read-only. Time stamp for the event. |
profile |
string | Read-only. Profile for the account. |
referrer_url |
EventUrl | Read-only. Omitted for mobile events. See EventUrl Data Type. |
type |
EventType |
Read-only. See EventType Data Type. |
useragent |
string | Read-only. Specifies the software the user is using, such as the web browser. |
visitor_id |
string | Read-only. |
_forwarding_visitor_ids |
string[] | Read-only. Contains the IDs of the visitor(s) forwarding this event. Used in the visitor stitching process. |
dataSourcePlatform
ValuesThe value of the dataSourcePlatform
property can be one of the following:
default adobe_launch affirm android braze cordova cSharp fileImport googleAMP google_tag_manager http_api_flattened hubspot_wf intercom iOS iterable |
java javascript mailchimp python RES roku salesforce sendgrid slack swift tiqJavascript tvOS watchOS zapier |
Property | Type | Description |
---|---|---|
dom |
Object | Read-only. Contains information about the page on which the event occurred (domain, query string, etc.) Omitted for mobile events. For more information, see Data Layer. |
firstparty_tealium_cookies |
Object | Read-only. Omitted for mobile events. Object contains properties specified in your data layer. |
js |
Object | Read-only. Omitted for mobile events. Object contains properties specified in your data layer. |
meta |
Object | Read-only. Omitted for mobile events. Object contains properties specified in your data layer. |
udo |
Object | Writable. Object contains properties specified in your data layer. Some properties prefixed with "tealium_" can be modified. See below for details. |
The data.udo
object is writable and the some of the udo
object properties can be modified, but cannot be deleted. The following udo
object properties can be modified:
The following udo
object properties cannot be modified:
Property | Type | Description |
---|---|---|
type |
"LIVE" | "BULK_IMPORT" | Specifies whether the event is from a live visit or is a bulk import event (from file import or omnichannel import). |
Property | Type | Description |
---|---|---|
domain |
string | Read-only. Domain of the URL. |
full_url |
string | Read-only. Full URL. |
path |
string | Read-only. Path from the URL. May be empty. |
query_params |
Object | Read-only. An Object that contains one or more key/value pairs. Each key/value pair specifies a query string in the URL. For example:"query_params": { |
querystring |
string | Read-only. Query string from the URL. |
scheme |
string | Read-only. Specifies the protocol to use for the web site, such as HTTP or HTTPS. |
Data transformation functions have the following execution limits:
When data transformation functions exceed these limits, a message is displayed in the Functions Overview and a yellow alert icon is displayed next to functions that have been throttled.
To view more detailed information for a throttled function, use the following steps:
flatten
LibraryThe flatten
library is a standard library that is imported in the default code for a data transformation function. This library provides the flatten()
utility, which converts a nested Object into an Object that is not nested. flatten()
returns an Object that contains strings and arrays of strings.
flatten()
accepts two parameters, as follows:
flatten(target[, options])
target
is the event Object passed to the data transformation function.options
is an Object that specifies how nested keys are handled during the conversion.The options
parameter contains the following properties:
Property | Data Type | Description |
---|---|---|
delimiter |
string, default is ".". | Specifies the character used to combine parent and child property names. |
prefix |
string, default is "". |
The |
ignoreKeys |
string[], default is []. | Specifies keys that should be omitted from the output. |
replaceKeys |
Object {string}, default is {}. | Specifies new names for keys using key/value pairs, where the key is the existing key in the object, and |
The following examples show how the options
properties are used. These examples use the following nested Object as the target to be flattened:
const object = { page: { id: 1 }, user: { id: 1 }, util: ["1", "2", "3"] };
delimiter
If delimiter
is "_", the following object is returned:
{ page_id: 1, util: ["1", "2", "3"] }
prefix
If prefix
is "fl", the following object is returned:
{ "fl.user.id": 1, "fl.page.id": 1, "fl.util": ["1", "2", "3"] }
ignoreKeys
If ignoreKeys
is ["page", "util"], the following object is returned:
{ "user.id": 1 }
replaceKeys
if replaceKeys
is defined as follows:
const replaceKeys = { "user": "", "page": "p" }
The following object is returned:
{ "id": 1, "p.id": 1, "util": ["1", "2", "3"] }Data Transformation Function Examples
import flatten from 'tealium/util/flatten'; const options = { delimiter: "_", ignoreKeys: ["array_of_strings"], replaceKeys: { "number": "float", "array_of_objects": "modified_array_of_strings", "ordinal": "" }, prefix: "t" } const output = flatten({ "boolean": true, "number": 12.34, "string": "value", "date": new Date(1631009413904), "array_of_strings": ["first", "second"], "array_of_arrays": [ [1, 2], [3, 4] ], "array_of_objects": [{ "ordinal": "first" }, { "ordinal": "second" }], "object": { "child_boolean": true, "child_number": 12.34, "child_string": "value", "child_array_of_strings": ["first", "second"], "child_array_of_arrays": [ [1, 2], [3, 4] ], "child_object": { "gchild_boolean": true, "gchild_number": 12.34, "gchild_string": "value", "gchild_array_of_strings": ["first", "second"], "gchild_array_of_arrays": [ [1, 2], [3, 4] ] } } }, options);
The following object is returned by flatten()
:
{ "t_boolean": "true", "t_float": "12.34", "t_string": "value", "t_date": "2021-09-07T10:10:13.904Z", "t_array_of_arrays": ["1","2","3","4"], "t_modified_array_of_strings": ["first","second"], "t_object_child_boolean": "true", "t_object_child_number": "12.34", "t_object_child_string": "value", "t_object_child_array_of_strings": ["first","second"], "t_object_child_array_of_arrays": ["1","2","3","4"], "t_object_child_object_gchild_boolean": "true", "t_object_child_object_gchild_number": "12.34", "t_object_child_object_gchild_string": "value", "t_object_child_object_gchild_array_of_strings": ["first","second"], "t_object_child_object_gchild_array_of_arrays": ["1","2","3","4"] }
Copyright All Rights Reserved © 2008-2022