- TLC Home Home
- Discussions & Ideas Discussions & Ideas
- Product Guides Product Guides
- Knowledge Base Knowledge Base
- Developer Docs Developer Docs
- Education Education
- Blog TLC Blog
- Support Desk Support Desk
This article reviews our best practices associated with implementing and managing your data layer.
In this article:
The goal of the data layer is to provide a set of variables that are vendor-neutral and easy to understand. The following best practices apply:
is_registered
, is_first_time_visitor
, is_logged_in
Pros | Cons |
---|---|
Creates a consistent naming convention. | Additional effort to transition vendor-specific variables to vendor-neutral naming convention. |
Easier for new users to understand what is available in your data layer and how each variable is used. |
|
Tealium Support is familiar with this convention. |
Use string values for all non-product variables. Boolean and numeric variables should be passed as strings.
For boolean values, we recommend using "1"
and "0"
instead of true
and false
. This approach is more stable and reduces confusion about the expected values in these variables.
Examples:
Boolean | Integer | |
---|---|---|
Correct |
is_registered : "1" |
order_total : "1234.56" |
Incorrect |
is_registered : true |
order_total : 1234.56 |
Pros | Cons |
---|---|
Tag templates expect strings and arrays. | None |
Minimizes testing effort during and after implementation,. |
Set product variables (price, quantity, ID, etc.) as arrays. The Universal Tag (utag.js) is designed to use arrays for all product variables. While it is possible to set product values in a comma-separated string, this approach is more prone to errors.
Array (Recommended):
product_id : ["prodID1","prodID2","prodID3"]
String:
product_id : "prodID1,prodID2,prodID3"
Pros | Cons |
---|---|
Same format expected by vendor tag templates. |
None |
Improves readability of the data layer. |
All pages of your site should include a variable called page_type
. This is used to determine the type of page the user is viewing. The suggested values include, but are not limited to:
Page |
Value |
---|---|
Home Page |
"home" |
Category / Product List |
"category" |
Product Detail |
"product" |
Search Results |
"search" |
Cart / Basket |
"cart" |
Checkout Flow (User Info, Billing Address, Shipping Address) |
"checkout" |
Order Confirmation / Thank You |
"confirmation" |
Pros | Cons |
---|---|
Gives a clear understanding of what kind of page the user is viewing |
Upfront development effort to add |
Many vendor tags utilize a page-type identifier to function properly |
You might already have a data layer object implemented on your site, such as the W3C Data Object or your own custom object. We recommend that these objects be converted to the Universal Data Object (UDO) utag_data using one of the available data layer converters.
Pros | Cons |
---|---|
Better compatibility with built-in functionality, such as load rules, data mappings, and Web Companion, |
Additional effort to implement. |
Reduces support costs to investigate issues with your custom object. |
In the page code, the Universal Data Object (utag_data) must be declared before the reference to the Universal Tag (utag.js). This ensures that the Universal Tag has all the data layer variables needed to evaluate load rules, extensions, and tags. A sample of your code can be accessed from Code Center.
Learn More: Code Center
Copyright All Rights Reserved © 2008-2021