Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. function clickProduct(productObj) {
  3.   dataLayer.push({
  4.     'event': 'productClick',
  5.     'ecommerce': {
  6.       'click': {
  7.         'actionField': {'list': 'Search Results'},      // Optional list property.
  8.         'products': [{
  9.           'name': productObj.name,                      // Name or ID is required.
  10.           'id': productObj.id,
  11.           'price': productObj.price,
  12.           'brand': productObj.brand,
  13.           'category': productObj.cat,
  14.           'variant': productObj.variant,
  15.           'position': productObj.position
  16.          }]
  17.        }
  18.      }
  19.   });
  20. }
  21.  
  22. jQuery(document).ready(function(){
  23.     var product1 = {
  24.       'name': 'Producto 1',                      // Name or ID is required.
  25.       'id': 'SKU-1',
  26.       'price': '10.00',
  27.       'brand': 'Ipad',
  28.       'category': 'Tech',
  29.       'variant': 'Gris',
  30.       'position': '1'
  31.     }
  32.     $('a.product1').click(clickProduct(product1), function(){
  33.         console.log('Listo');
  34.     });
  35.  
  36. });
  37. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement