window.dataLayer = window.dataLayer || [];
// Google Tag Manager (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-KZJCLJF'); // End Google Tag Manager
if(( window.location.pathname || '').indexOf('/confirm') > -1 ) { console.log('firing on confirm page - datalayer', data); var attendee = data.attendee || {}; var eventObject = data.event || {}; var order = data.order || {}; console.log(order); var attendeeType = attendee['1435768870720001FK0D'] || ''; var GoogleAnalytics = attendee['gaclid'] || ''; var totalTax = 0; var orderId = order['orderId'] || ''; var orderNum = order['orderNum'] || ''; var regcodes = (order.items || []) .filter(function(i){ return i !== undefined && i !== null }) .map(function(i){ return i.regcode}).join(','); var products = (order.items || []).map(function(item){ totalTax += (item.tax || 0); return { 'brand': '', // set to empty string 'category': attendeeType, // Attendee Categorization updated by Adi // Adi commented 'coupon': isMedia, // I am PRESS or MEDIA yes or no 'id': '', // Product ID, set to empty string for now 'name': (item.name || ''), // Product Name 'price': (item.price || 0).toString(), // unit price 'variant': '', // set to empty string 'quantity': item.quantity || 0 // always set to one. If more than 1 pass was purchased, add another product sub-array below } }); console.log('products', products) dataLayer.push({ 'dimension2': GoogleAnalytics ||'', //gacid 'dimension19': attendee.attendeeId || '', //GUID 'event': 'transaction', // do not change 'ecommerce': { 'purchase': { 'actionField': { 'affiliation': eventObject.name || '', // Conference Name and Year 'coupon': regcodes, 'revenue': (order.totalAmount || '0').toString(), // Total transaction value (incl. tax and shipping) do not include currency symbol 'shipping': '', // set to empty string 'tax': (totalTax || '0').toString(), // constant 0 or actual value when applicable 'id': orderNum // Transaction ID assigned by system. Required for purchases and refunds. }, 'products': products.map( product => ({ 'brand': '',//set to empty string 'category': product.category, //updated by Adi pass type 'coupon': regcodes, //regcode used 'id': product.id,// productid 'name': (product.name || ''),// updated by Adi Pass name 'price': (product.price || 0).toString(),// updated by Adiuint price 'variant':'',//set to empty string 'quantity':product.quantity,//Allways set to one.if more then one pass as purchaced, add another product sub Array below })) } } }); }