function trackEcommerce() { function gaAddTrans(orderID, store, total, tax, shipping, city, state, country) { console.log('before ga',ga) ga('ecommerce:addTransaction', { id: orderID, affiliation: store, revenue: total, tax: tax, shipping: shipping, city: city, state: state, country: country }); } function gaAddItems(orderID, sku, product, variation, price, qty) { ga('ecommerce:addItem', { id: orderID, sku: sku, name: product, category: variation, price: price, quantity: qty }); } function gaTrackTrans() { ga('ecommerce:send'); } function gtagAddTrans(orderID, store, total, tax, shipping, city, state, country) { this.transaction = { transaction_id: orderID, affiliation: store, value: total, tax: tax, shipping: shipping, currency: 'CAD', items: [] }; } function gtagAddItem(orderID, sku, product, variation, price, qty) { this.transaction.items.push({ id: sku, name: product, category: variation, price: price, quantity: qty }); } function gtagTrackTrans() { gtag('event', 'purchase', this.transaction); gtag('event', 'conversion', { 'send_to': 'AW-1044883083/afxTCIj1lmUQi82e8gM', 'value': this.transaction.value, 'currency': this.transaction.currency, 'transaction_id': this.transaction.transaction_id }); this.transaction = null; } if (typeof gtag === 'function') { this._addTrans = gtagAddTrans; this._addItem = gtagAddItem; this._trackTrans = gtagTrackTrans; } else if (typeof ga === 'function') { this._addTrans = gaAddTrans; this._addItem = gaAddItems; this._trackTrans = gaTrackTrans; } } var pageTracker = new trackEcommerce();
888-897-3275