gtag('js', new Date());
gtag('config', 'AW-981964034');
function trackEcommerce() {
function gaAddTrans(orderID, store, total, tax, shipping, city, state, country) {
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,
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-981964034/KX6wCJ7V_gYQgqqe1AM',
'value': this.transaction.value,
'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();