Revenue always zero for addtransaction - google-analytics

I am implementing addItem and addTransaction on a web shop's cart page. Once an order has been placed, I go through the carts content and add each individual item as an addItem with google analytics ecommerce plugin, then I create the transaction and send it altogether to google.
What happens in google analytics is that all transactions show up as having 0 revenue, 0 tax and 0 shipping - but if I enter one individual transaction I can see the item price, name and quantity ordered.
This is the final executing google analytics code once rendered:
ga('require', 'ecommerce');
ga('ecommerce:addItem', { 'id': '143506092300', 'name': 'PRODUCT NAME #1 , COLOR Black', 'price': '229.00', 'quantity': '1'});
ga('ecommerce:addTransaction', { 'id': 'xxx123', 'affiliation': 'Web Shop Name', 'revenue': '229.00', 'shipping': '0.00', 'tax': '45.80'});
ga('ecommerce:send');
Does anyone see what I'm missing here?

So I had two issues:
the ID in the addItem block was actually the product ID, but it is supposed to be the transaction ID.
The solution was to have the same ID in all addItem calls and this ID in the transaction call.
Additionally, the transaction code should appear before the addItem calls, the following works for me:
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', { 'id': '143506092300', 'affiliation': 'Web Shop Name', 'revenue': '229.00', 'shipping': '0.00', 'tax': '45.80'});
ga('ecommerce:addItem', { 'id': '143506092300', 'name': 'PRODUCT NAME #1 , COLOR Black', 'price': '229.00', 'quantity': '1'});
ga('ecommerce:send');

Related

Enhanced Ecommerce Not Passing Data To GA

I'm trying to get enhanced ecommerce data flowing to GA but after 2 tries, something is missing/not correct with the set up.
Here are screenshots that show the tag is firing, enhanced ecommerce is enabled, and the event is showing in GA - however the purchase event values like revenue etc aren't being recorded in GA.
tag details values
tag details names
tag configuration
data layer
tags fired
GA event
ecommerce setup
Any assistance here would be greatly appreciated!
Thanks,
the data layer values are not correct, in order to record a transaction, you need to add purchase, not transaction
{
'ecommerce': {
'purchase': {
'actionField': {
'id': 'RL00195',
'affiliation': 'Relish',
'revenue': '12.99',
'tax':'2.16',
'shipping': '4.17',
'coupon': '',
'currency':'GBP'
},
'products': [{
'name': 'Category Snap',
'id': 'AB005',
'price': '6.66',
'brand': '',
'category': '',
'variant': '',
'quantity': 1,
'coupon': ''
}]
}
}
this should be the data layer values

Google analytics add to cart quantity

We use this code format in google analytics corresponding to add to cart feature of google analytics.
function addToCarts() {
ga('ec:addProduct', {
'id': '12334',
'name': 'methyly methly',
'category': 'Clothing',
'brand': '',
'variant': '',
'price': '100',
'quantity': 40
});
ga('ec:setAction', 'add');
// send this using event
ga('send', 'event', 'enhanced ecommerce', 'button click', 'add to cart');
}
addToCarts();
Where in google analtics convertion tab----->Enhanced ecommerce i can see quantity of product added?.Their is one section in google analytics conversion---->Enhanced ecommerce--->shopping behaviour--->Products add to cart(metric). But it only reflect how many times product was added to cart but not how many qunatity of that product to cart.
You can find the quantity in Summary tab of the report: Conversions-->Ecommerce-->Product performace (Summary tab).

Recording event data problem in google analytics ecommerce

I'm implementing enhanced ecommerce in Google Analytics and I have a problem.
When the purchase of a product is made, it's redirected to a thanks page and that's where the Purchase event is sent to Analytics.
ga('require', 'ec');
ga('set', 'currencyCode', 'EUR');
ga('ec:addProduct', {
'id': 'prueba-001',
'name': 'Prueba',
'brand': 'Prueba',
'category': 'Prueba',
'variant': 'Prueba',
'price': 10.50
});
ga('ec:setAction', 'purchase', {
'id': 't-prueba-01',
'revenue': 5.50
});
ga('send', 'pageview');
The 'purchase' event is recorded perfectly, but the addProduct event is not quite right, the unique purchases of each product are registered but nothing else.
I don't know what else to do, I have followed the steps in the documentation and the problem persists.
Edit:
Sales report
Try to use quote for price and revenue (for consistency with the documentation) and above all add the quantity parameter to the product.

custom dimension with product and transaction hit

I have some problems with using custom dimensions with enhanced ecoomerce.
code below.
I would like to add 3 custom dimensions as product scopes and it works. but still I would like to add one custom dimension to transaction as hit scope. My below code doesn't works for dimension1. where should I place 'dimension1': 'zamowienie' to have info about the whole transaction, not olny products?
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': '194771', // Transaction ID. Required for purchases and refunds.
'dimension1': 'zamowienie',
'revenue': '35.27', // Total transaction value (incl. tax and shipping
'shipping': '5.99'
},
'products': [{
'dimension2': 'JP Delaney',
'dimension3': 'jak nowa',
'dimension4': 'ksiazka',
'name': 'Lokatorka', // Name or ID is required.
'id': '9788375150780',
'price': '27.99',
'quantity': 1 // Optional fields may be omitted or set to empty string.
},
{
'dimension2': 'Kelly Creagh',
'dimension3': 'widoczne ślady używania',
'dimension4': 'ksiazka',
'name': 'Nevermore T.1 Kruk',
'id': '9788376860657',
'price': '7.28',
'quantity': 1
}]
}
}
});
as long as you're using product scopes custom dimensions you need to put then alongside other product fields in the product object. In your example that would look like
{
'dimension1': 'some value',
'dimension2': 'JP Delaney',
'dimension3': 'jak nowa',
'dimension4': 'ksiazka',
'name': 'Lokatorka', // Name or ID is required.
'id': '9788375150780',
'price': '27.99',
'quantity': 1
},
however, this would make sense only to report persistent product properties otherwise your products wouldn't be aggregated properly in the reports. For example, having a product dimension value of 'zamowienie' in the transactions products but not in checkout products may result in missing that checkout steps in the funnel report with dimensions1 since those would be treated as different products.

google analytics not recording transactions

Im seeing visitors, page request, etc, but no transactions/conversions are appearing in google analytics. It was working recently but since my last code push it hasn't recorded a transaction (even though there have been many in that time).
I have trawled through my change list but can't see anything which could cause this to happen, and my dataLayer code seems to be in order.
I've enabled previewing in Google Tag Manager and this is the output:
I can also see the following request in Google Tag Assistant Chrome Extension, so it looks like the trigger is firing:
www.google-analytics.com/collect?v=1
&_v=j41
&a=370988122
&t=transaction
&_s=1
&dl=http%3A%2F%2Fblah.com%2Fcheckout%2Fppexp%2Fpayment
&ul=en-us
&de=UTF-8
&dt=ACME%20Checkout
&sd=24-bit
&sr=2560x1440
&vp=2543x948
&je=0
&fl=20.0%20r0
&_u=SCCAAAATI~
&jid=
&cid=1209500833.1453740341
&tid=UA-XXXXXXXX-X
&gtm=GTM-XXXXXX
&ti=1135114249
&ta=ACME
&tr=27.09
&ts=3.09
&tt=4.51
&z=602872780
www.google-analytics.com/collect?v=1
&_v=j41
&a=370988122
&t=item
&_s=2
&dl=http%3A%2F%2Fblah.com%2Fcheckout%2Fppexp%2Fpayment
&ul=en-us
&de=UTF-8
&dt=ACME%20Checkout
&sd=24-bit
&sr=2560x1440
&vp=2543x948
&je=0
&fl=20.0%20r0
&_u=SCCAAAATI~
&jid=
&cid=1209500833.1453740341
&tid=UA-XXXXXXXX-X&
gtm=GTM-XXXXXX
&ti=1135114249
&ic=Art%20Nouveau
&in=Art%20Print%20Size%20Small%20Poster
&iv=Art%20Print
&ip=24
&iq=1
&z=35031258
Any suggestions as to how to proceed?
It looks like you code doesn't match the standard purchase snippet and usually causes transactions to be received and not processed.
Try update your code to match:
https://developers.google.com/tag-manager/enhanced-ecommerce#purchases
<script>
// Send transaction data with a pageview if available
// when the page loads. Otherwise, use an event when the transaction
// data becomes available.
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': 'T12345', // Transaction ID. Required for purchases and refunds.
'affiliation': 'Online Store',
'revenue': '35.43', // Total transaction value (incl. tax and shipping)
'tax':'4.90',
'shipping': '5.99',
'coupon': 'SUMMER_SALE'
},
'products': [{ // List of productFieldObjects.
'name': 'Triblend Android T-Shirt', // Name or ID is required.
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1,
'coupon': '' // Optional fields may be omitted or set to empty string.
},
{
'name': 'Donut Friday Scented T-Shirt',
'id': '67890',
'price': '33.75',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Black',
'quantity': 1
}]
}
}
});
</script>
Pay special attention to the numbers and ensure that quantity is the only element that isn't in quotation. Transaction id, product id, shipping tax, etc are all included in single quotes.
As nyuen suggested, I waited 24 hours and my transactions started to appear.
The underlying issue was that my triggers had been changed and it took google analytics a bit of time to start recording transactions under the new triggers.

Resources