The Lego Data Layer
Digital Event Grammar: 
subject + verb + object + context 
Ecommerce:
Files downloaded, buttons and 
links clicked, pages seen…. 
Stuff that users interacted 
with directly (the object) 
We track it, then classify it.
Then came 
Enhanced Ecommerce 
... enables the measurement of user 
interactions with products on ecommerce 
websites ...
It doesn’t “fit” 
Sometimes product is object, other times it’s part of context.
Entity = a thing that’s of 
particular interest to the business. 
The shopper 
The product 
The product category 
The transaction 
The shopping visit aka the checkout 
The promotion 
The campaign
It’s not the clicked button that 
counts (the object). 
But the business entity 
that click is related to.
Link interactions to the 
business entities 
they’re related to at 
data collection time. 
subject + verb + object + context + entity
The Entity 
Dictionary: 
- Standalone attributes 
- Gained attributes
Interaction -> system 
composed of business entities
Simply “slot” entities 
into the structure of the 
new interaction.
Especially when you have 
parent-child relationships.
New attributes 
automatically “travel” with 
the entity. 
They trickle through to the 
entities and interactions 
they’re a part of.
How does it work in practice
Interaction recipe for GTM… 
"added_product_to_basket": { 
"action": { 
"category": "shopping", 
"timestamp": "1410962241" 
}, 
"user": <user dict>, 
"object": { 
"type": "product", 
"dict": <product dict> 
}, 
"context": { 
"notification": <notification dict>, 
"checkout": <checkout dict> 
} 
}
…human friendly for us 
added_product_to_basket: 
action: 
category: shopping 
timestamp: 1410962241 
user: <user dict> 
object: 
type: product 
dict: <product dict> 
context: 
notification: <notification dict> 
checkout: <checkout dict>
Get devs to create helpers 
who get the dictionaries 
ready.
Call on the helpers immediately 
after the interaction occurs.
Meet the entity dictionary workhorse
Automatically 
highlight changes 
+ product.cohort_added 
+ product.date_added 
! 
- product.brand.variation
Automatically 
create human friendly spec 
product 
id // server-side / client-side markup 
variations 
number // server-side 
! 
brand 
name // server-side 
!
Automatically 
create precise JSON spec 
{ 
"product": { 
"id": "[id of product]", 
"name": "[name of of product]", 
"variations": { 
"number": "[number of variations available]" 
}, 
"brand": { 
"name": "[manufacturer brand sold under]" 
} 
} 
}
Automatically 
create HTML5 markup spec 
<* 
data-entity=“product” 
data-product-id=“value” 
data-product-context-collection-position=“ 
value” 
>
Special thanks…. 
Alex & Yali 
snowplowanalytics.com 
! 
Simo Ahava 
simoahava.com
Data Layer = like a box of 
ready-made Lego characters 
(but for analytics). 
In-depth blog post series: 
http://clearclu.es/LegoLayer 
@carmenmardiros

The Lego Data Layer

  • 1.
  • 2.
    Digital Event Grammar: subject + verb + object + context Ecommerce:
  • 3.
    Files downloaded, buttonsand links clicked, pages seen…. Stuff that users interacted with directly (the object) We track it, then classify it.
  • 4.
    Then came EnhancedEcommerce ... enables the measurement of user interactions with products on ecommerce websites ...
  • 5.
    It doesn’t “fit” Sometimes product is object, other times it’s part of context.
  • 6.
    Entity = athing that’s of particular interest to the business. The shopper The product The product category The transaction The shopping visit aka the checkout The promotion The campaign
  • 7.
    It’s not theclicked button that counts (the object). But the business entity that click is related to.
  • 8.
    Link interactions tothe business entities they’re related to at data collection time. subject + verb + object + context + entity
  • 9.
    The Entity Dictionary: - Standalone attributes - Gained attributes
  • 10.
    Interaction -> system composed of business entities
  • 11.
    Simply “slot” entities into the structure of the new interaction.
  • 12.
    Especially when youhave parent-child relationships.
  • 13.
    New attributes automatically“travel” with the entity. They trickle through to the entities and interactions they’re a part of.
  • 14.
    How does itwork in practice
  • 15.
    Interaction recipe forGTM… "added_product_to_basket": { "action": { "category": "shopping", "timestamp": "1410962241" }, "user": <user dict>, "object": { "type": "product", "dict": <product dict> }, "context": { "notification": <notification dict>, "checkout": <checkout dict> } }
  • 16.
    …human friendly forus added_product_to_basket: action: category: shopping timestamp: 1410962241 user: <user dict> object: type: product dict: <product dict> context: notification: <notification dict> checkout: <checkout dict>
  • 17.
    Get devs tocreate helpers who get the dictionaries ready.
  • 18.
    Call on thehelpers immediately after the interaction occurs.
  • 19.
    Meet the entitydictionary workhorse
  • 20.
    Automatically highlight changes + product.cohort_added + product.date_added ! - product.brand.variation
  • 21.
    Automatically create humanfriendly spec product id // server-side / client-side markup variations number // server-side ! brand name // server-side !
  • 22.
    Automatically create preciseJSON spec { "product": { "id": "[id of product]", "name": "[name of of product]", "variations": { "number": "[number of variations available]" }, "brand": { "name": "[manufacturer brand sold under]" } } }
  • 23.
    Automatically create HTML5markup spec <* data-entity=“product” data-product-id=“value” data-product-context-collection-position=“ value” >
  • 24.
    Special thanks…. Alex& Yali snowplowanalytics.com ! Simo Ahava simoahava.com
  • 25.
    Data Layer =like a box of ready-made Lego characters (but for analytics). In-depth blog post series: http://clearclu.es/LegoLayer @carmenmardiros