About Hosted Data Layer

About Hosted Data Layer

by on ‎03-21-2017 01:50 PM - edited Wednesday by Community Manager (1,535 Views)

Hosted Data Layer facilitates the use of statically hosted data for the purpose of supplementing the dynamic on-page data layer of your website. Although the data layer implemented on your website is useful in capturing real-time information, it can be a challenge to build out your data layer to contain all the data with value to your organization. Hosted Data Layer provides a convenient mechanism to upload your static data to the Tealium mCDN, from where it can easily be accessed by your web pages to enrich the on-page data. This article provides a feature overview and a description of the components required for a full implementation of Hosted Data Layer.

This article covers the following topics:

Table of Contents Placeholder

How It Works

Hosted Data Layer utilizes micro data layer objects associated to a variable in your on-page data layer. The Hosted Data Layer object is a text file that contains a JSON object in which the key/value pairs represent the micro data layer. This file is uploaded to the CDN using the Hosted Data Layer API. The on-page data layer contains lookup variables, which are configured in the Hosted Data Layer Extension in iQ, that are used to determine which Hosted Data Layer object to fetch from the CDN.

The following sections provide a description of the two (2) required components, the Hosted Data Layer API and the Hosted Data Layer Extension:

Hosted Data Layer API

The Hosted Data Layer API allows you to upload the supplemental data to the CDN in a flat JSON object called a Hosted Data Layer object. The API enables the programmatic processing of large amounts of data to be used as Hosted Data Layer objects.

The following example shows the contents of a Hosted Data Layer object:

{
    "product_category"           : ["Accessories"],
    "product_brand"              : ["Acme"],
    "product_sku"                : ["GEN-PRD-BLU"],
    "product_has_free_shipping"  : ["0"],
    "product_has_instore_pickup" : ["1"]
}

As shown in the example, a Hosted Data Layer object looks similar to the data layer object on your website. While the on-page data layer describes the page and customer interactions, the Hosted Data Layer object provides additional attributes based on a specific variable on the page. Additional attributes for a specific product are provided in the example.

For detailed instructions, see How to use the Hosted Data Layer API.

Hosted Data Layer Extension

The Hosted Data Layer extension is the component that combines the hosted data with the in-page data. The extension fetches the hosted hosted data layer objects and combines the contents of each object with the on-page data layer and calls utag.view() with the merged object. The extension is configured to identify the data layer variables, also known as lookup variables, that are used to determine which Hosted Data Layer objects will be fetched from the CDN.

For detailed instructions, see How to set up the Hosted Data Layer extension.

Lookup Variable

A lookup variable identifies which variable in the on-page data layer will be used to fetch the appropriate Hosted Data Layer object for that page. The lookup variable is the shared link between the Hosted Data Layer objects and the Hosted Data Layer extension.

You must identify your lookup variables first and then use the expected values of each variable to name your Hosted Data Layer objects. For example, if your lookup variable is item_id and one of the values is "123", the corresponding Hosted Data Layer object will be named "123.js".

Order of Operations 

The enrichment process begins when utag.js file loads on the page. The Hosted Data Layer extension runs first and delays page tracking (by setting utag.cfg.noview=true) to ensure that no tags, load rules, or extensions are evaluated until the hosted data is retrieved. While the extension is running, the lookup variables are identified and each of their values is used to fetch the matching hosted data layer object from the CDN. If a hosted data layer object is found, the data from that object is combined with the on-page data layer into a temporary object. After all lookup variables are processed and a new data layer object is finalized, the extension triggers utag.view() with that new object.

In summary:

  1. The Hosted Data Layer API is used to upload JSON data files to the CDN.
  2. The Hosted Data Layer extension is configured in iQ with identified lookup variables.
  3. utag.js combines the on-page data layer with the fetched hosted data layer objects and calls utag.view().

hosted-data-layer-diagram.jpg

Use Case: Supplementing Product Data

The following is a use case to illustrate how Hosted Data Layer can be used.

  • You have a database of information for the products you sell on your website.
  • The basic product attributes, such as "ID", "Price", and "Name", are readily available to your web application and currently populated in the data layer on your page.
  • An offline system that is not available to your web application contains additional product attributes that you want to add to the on-page data layer, such as "SKU", "In Store Availability", "Free Shipping Status", and "Brand".

The following steps describe the implementation process for this use case:

  1. Identify Lookup Variables
    The on-page data layer contains product_id, which is also an identifier in the offline data and a good candidate for a lookup variable.

  2. Create/Upload Hosted Data Layer Objects
    A program is created to export the offline product data into JSON data files, which are named according to the expected values of product_id.
    For example, if the on-page data layer contains product_id=["PRD123"] , then a matching Hosted Data Layer file named "PRD123.js" is created.
    A separate file containing the value of product_id is created for every product.

  3. Configure Hosted Data Layer Extension
    With the lookup variable identified and hosted data layer objects uploaded, the Hosted Data Layer Extension is then added and configured to use product_id.
    Although your on-page data layer may only have  product_id available, you have used the Hosted Data Layer API to upload additional product data. The lookup variable is now product_id, which means that the values of the product identifier variables determine the names of the hosted data layer objects.
    The following table shows the end result of applying the enrichment process.

    On-Page Data Layer

    utag_data

    {
        "page_type"  : "product",
        "product_id" : ["PRD123"]
    }

    Hosted Data Layer Object

    PRD123.js

    {
        "has_free_shipping"  : ["0"],
        "has_instore_pickup" : ["1"]
    }

    Merged Data Layer

    (sent directly to utag.view())

    utag.view({
        "page_type"          : "product",
    "product_id" : ["PRD123"]
    "has_free_shipping" : ["0"], "has_instore_pickup" : ["1"] })