Browser data layer

The browser data layer can be used to supply data to Seeka that is relied on to enrich and automatically detect events and enrich identities with traits.

This approach is similar to the handler approach to providing data and context to Seeka, but is more appropriate for implementations where the data is available prior to the page load such as in a server-side rendered application.

The data layer will always take precedence over the handler definitions.

Schema

  • Seeka.context.product - Object containing the context to the currently viewed or active product. See this reference for a list of available properties.
  • Seeka.context.cart - Object containing the context to the currently viewed or active shopping cart. See this reference for a list of available properties.
  • Seeka.context.user - Object containing the currently logged in or active user. See this reference for a list of available properties.
  • Seeka.context.search - Object containing the context of the current search made by the user. See this reference for a list of available properties.
  • Seeka.context.tracking.defaults - Object containing the tracking defaults. Values here will override the `tracking.defaults supplied in the SDK configuration. See this reference for a list of available properties.
  • Seeka.context.tracking.analytics.autoCollection.activityNames - String array containing the activities to attempt to automatically track. Value will override the tracking.analytics.autoCollection.activityNames supplied in the SDK configuration. See this reference for a list of available values.
  • Seeka.context.window.location - Replaces the standard window.location browser object.
  • Seeka.context.window.localStorage - Replaces the standard window.localStorage browser object.
  • Seeka.context.window.sessionStorage - Replaces the standard window.sessionStorage browser object.
  • Seeka.context.document.referrer - Replaces the standard document.referrer browser object.
  • Seeka.context.document.title - Replaces the standard document.title browser object.
  • Seeka.context.navigator.userAgent - Replaces the standard navigator.sessionStorage browser object.
  • Seeka.context.navigator.language - Replaces the standard navigator.language browser object.

Usage

The data layer should be configured in the <head> of the page, before the Seeka SDK is loaded.

Examples

Currently viewed product

<head>
  <!-- ... other tags -->
  <script>
    window.Seeka = window.Seeka || {};
    window.Seeka.context = window.Seeka.context || {};
    window.Seeka.context.product = {
      productIdentifier: "2cbbc8fd00ac4a79a2855c77eaa029d7",
      productName: "Super awesome product",
      sku: "SKU-1234567890",
      // ...other properties
    };
  </script>
</head>

Current cart

<head>
  <!-- ... other tags -->
  <script>
    window.Seeka = window.Seeka || {};
    window.Seeka.context = window.Seeka.context || {};
    window.Seeka.context.cart = {
      cartIdentifier: "5114a9b2e64e445f96df6de45b2696dc",
      checkoutIdentifier: "79180d2707104649b65a0f3577f349ed",
      products: [
        {
          productIdentifier: "1234567890",
          productName: "Super awesome product",
          sku: "SKU-1234567890",
          // ...other properties
        },
      ],
    };
  </script>
</head>

Logged in user

<head>
  <!-- ... other tags -->
  <script>
    window.Seeka = window.Seeka || {};
    window.Seeka.context = window.Seeka.context || {};
    window.Seeka.context.user = {
      email: ["john.smith@testing.com"],
      firstName: ["John"],
      lastName: ["Smith"],
      // ...other properties
    };
  </script>
</head>

Product search

<head>
  <!-- ... other tags -->
  <script>
    window.Seeka = window.Seeka || {};
    window.Seeka.context = window.Seeka.context || {};
    window.Seeka.context.search = {
      searchText: "Super awesome product",
    };
  </script>
</head>

Tracking defaults

<head>
  <!-- ... other tags -->
  <script>
    window.Seeka = window.Seeka || {};
    window.Seeka.context = window.Seeka.context || {};
    window.Seeka.context.tracking = window.Seeka.context.tracking || {};
    window.Seeka.context.tracking.defaults = {
      currencyCode: "USD",
    };
  </script>
</head>