Reputation: 128
We have implemented Google Analytics Ecommerce tracking in our web site. We have noted that there are some missing transactions from Google Analytics. Only some data get missing and other transactions are recorded correctly.
There is no specific pattern to those missing orders (e.g. the products that are selected, the device they are using...etc).
Below is the code snippet that push transaction data to analytics.
var products = [];
for (i = 0; i < cart.lines.length; i++) {
var cartItem = cart.lines[i];
if (cartItem != null && cartItem != 'undefined') {
products.push({
'name': cartItem.cartProduct.name + ' ($' + cartItem.cost + ')',
'id': cartItem.cartProduct.id ,
'price': cartItem.cost,
'brand': 'My Brand XXX',
'category': cartItem.category,
'variant': 'My Brand XXX',
'quantity': 1 // Iterating item by item therefore hardcoding quantity to 1
});
}
}
// Pushing ecommerce transaction data to data layer
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': cart.referenceNumber, // Transaction ID. Required for purchases and refunds.
'affiliation': store.name,
'revenue': cart.totalPrice, // Total transaction value (incl. tax and shipping)
'tax': 0,
'shipping': cart.deliveryCharge,
'coupon': ''
},
'products': products
}
},
'event': 'purchase'
});
}
Note that I have the fully populated 'cart' and 'store' objects accessible. Appreciate if anyone could help to figure out what's causing this.
Upvotes: 1
Views: 4352
Reputation: 299
If you use a third-party payment processor for some but not all transactions - common example, you accept credit cards on your website but you also accept PayPal payments where the buyer is taken to the PayPal site to complete the transaction - the ones who leave your site to pay are often not counted.
Two reasons: one, many buyers leave straight from PayPal - they never view the order confirmation page where your tracking code is set to send the data to GA.
Two, they're tracked separately because they've technically left your website and then returned, so you need to set up cross-domain tracking to associate them with the correct user session.
(I know this answer is rather late for the OP but thought it might help someone else in a similar situation.)
Upvotes: 0
Reputation: 146
Well, Your code seems fine. There isn't any specific way to identify the way what is causing this issue. You can implement exception tracking in above particular code, by that you will get to know the possible reason which is causing the issue.
To implement exception tracking using GTM you need to wrap up the above code in try catch block and in catch block you push the datalayer event with the exception detail. On other side in GTM configure the exception tracking tag.
Hope this will help you. Let me know in case of any help needed to implement exception tracking.
Upvotes: 1