Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function clickProduct(productObj) {
- dataLayer.push({
- 'event': 'productClick',
- 'ecommerce': {
- 'click': {
- 'actionField': {'list': 'Search Results'}, // Optional list property.
- 'products': [{
- 'name': productObj.name, // Name or ID is required.
- 'id': productObj.id,
- 'price': productObj.price,
- 'brand': productObj.brand,
- 'category': productObj.cat,
- 'variant': productObj.variant,
- 'position': productObj.position
- }]
- }
- }
- });
- }
- jQuery(document).ready(function(){
- var product1 = {
- 'name': 'Producto 1', // Name or ID is required.
- 'id': 'SKU-1',
- 'price': '10.00',
- 'brand': 'Ipad',
- 'category': 'Tech',
- 'variant': 'Gris',
- 'position': '1'
- }
- $('a.product1').click(clickProduct(product1), function(){
- console.log('Listo');
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement