Facebook
From PlĂ­nio, 3 Years ago, written in HTML5.
Embed
Download Paste or View Raw
Hits: 125
  1. var dataLayer = window.dataLayer || [];
  2. dataLayer.push({
  3.   'event': 'transaction',
  4.   'ecommerce': {
  5.     'purchase': {
  6.       'actionField': {
  7.         'id': 'T12345',        // Transaction ID. Required          
  8.         'affiliation': 'Online Store',
  9.         'revenue': '35.43',   // Total transaction value (incl. tax and shipping)
  10.         'tax':'4.90',
  11.         'shipping': '5.99',
  12.         'coupon': 'SUMMER_SALE'
  13.       },
  14.           'products': [{          // List of productFieldObjects.
  15.         'name': 'T-Shirt 2',  // Name or ID is required.
  16.         'id': '12345',
  17.         'price': '15.25',
  18.         'brand': 'Measureschool',
  19.         'category': 'Shirts',
  20.         'variant': 'Gray',
  21.         'quantity': 1,
  22.         'coupon': ''  // Optional fields may be omitted or set to empty string.
  23.        },
  24.        {
  25.         'name': 'T-Shirt 1',
  26.         'id': '67890',
  27.         'price': '33.75',
  28.         'brand': 'Measureschool',
  29.         'category': 'Shirts',
  30.         'variant': 'Black',
  31.         'quantity': 1
  32.        }] //expand this array if more product exists
  33.     }
  34.   }
  35. });
  36.