I'm seeing a big difference between the reported Revenue and the Product Revenue on transactions. For example, this is what I see for Revenue for a transaction:
And this is the (correct) amount that shows up when I click into that Transaction ID.
The Revenue of the transaction and the Product Revenue are two differents metrics and comes from 2 differents parts of the code. Let me explain you what is maybe happening.
This is the transaction code for the enhanced ecommerce, but it can happens in all the versions of the ecommerce snippet
ga('ec:addProduct', { // Provide product details in an productFieldObject.
'id': 'P12345', // Product ID (string).
'name': 'Android Warhol T-Shirt', // Product name (string).
'category': 'Apparel', // Product category (string).
'brand': 'Google', // Product brand (string).
'variant': 'black', // Product variant (string).
'price': '29.20', // Product price (currency). <-- UnitPrice
'coupon': 'APPARELSALE', // Product coupon (string).
'quantity': 1 // Product quantity (number). <--Quantity
});
ga('ec:setAction', 'purchase', { // Transaction details are provided in an actionFieldObject.
'id': 'T12345', // (Required) Transaction id (string).
'affiliation': 'Google Store - Online', // Affiliation (string).
'revenue': '37.39', // Revenue (currency). <<- Revenue
'tax': '2.85', // Tax (currency).
'shipping': '5.34', // Shipping (currency).
'coupon': 'SUMMER2013' // Transaction coupon (string).
});
The product Revenue is based on the multiplication of the Quantity * UnitPrice (calculated in each transaction) and the Transaction Revenue belongs to the 'purchase' object.
Google Analytics dosent matter any logic, for example, you can have in one transaction a product price of $99.99 with Quantity of 2 and in the same transaction declarate the reveue as $2 and it's ok for Analytics. And we know that is not right.
So, you need to make that number match, The common mistakes here are:
Transactions apply Discount -> Sum of product dont have discount applied
Transactions don't apply Discount -> Sum of product have discount applied
Transaction is A -> Sum of Product is C
Google does not add product values up - instead the product revenue and the transaction revenue is passed to GA via different variables in the tracking code, and the reports show the respective variable values.
So I guess somebody passed in the wrong value (I vaguely suspect a wrong decimal separator). You need to check your transaction code.
Related
I want to track total revenue of products ordered if product is of X category.
I tried adding extra parameter to action field
'actionField': {
'id': '${fn:escapeXml(orderData.code)}', // Document number
'revenue': '${orderData.totalPrice.value}', // Total transaction value (excl. tax)
'tax': '${orderData.totalTax.value}',
'xcategoryproductrevenue': '${orderData.totalTax.value}',
}
I am getting data sent to the ecommerce view on my analytics dashboard - but the items aren't being attached to the transaction - it looks like the items are coming through as transactions as well.
Am I mistaken or should the items be attached to the transaction? What am I dong wrong here.
// Build e-commerce items for each item groups
let items = _.map(basket.item_groups, (group) => {
let category = group.type && 'events' || 'products';
let id = group.type && `tt-${group.type}` || `pa-${group.product_attribute}`;
return {
'id': id,
'name': group.description,
'sku': id,
'category': category, // causes problems if removed entirely
'price': group.price,
'quantity': group.quantity,
'currency': basket.currency,
};
});
let transaction = {
'id': basket.id, // Transaction ID. Required.
'affiliation': basket.payment_venue, // Affiliation or store name.
'revenue': basket.total_price,
'shipping': 0,
'tax': basket.taxes,
};
this.call(`${this.namespace}.ecommerce:addTransaction`, transaction);
_.each(items, (item) => {
this.call(`${this.namespace}.ecommerce:addItem`, item);
});
this.call(`${this.namespace}.ecommerce:send`);
It looks like the id property for your items isn't set to the transaction ID, which it needs to be. Instead you're giving each product its own SKU/ID in both the id and sku fields.
When defining the item, it looks like you just need:
'id': basket.id,
In the classic ecommerce tracking, the items and transactions are sent as individual hits (unlike Enhanced Ecommerce), so every item needs to be linked to the transaction. You're instead assigning your products to transactions with the SKU instead of the transaction ID, which is why they show up as transactions without revenue.
I've been searching Google but really there is no answer. Perhaps any of you guys here know: would the code below work:
ga('ec:setAction', 'purchase', { // Transaction details are provided in an actionFieldObject.
'id': 'T12345', // (Required) Transaction id (string).
'affiliation': 'Google Store - Online', // Affiliation (string).
'revenue': '37.39', // Revenue (currency).
'tax': '2.85', // Tax (currency).
'shipping': '5.34', // Shipping (currency).
'coupon': 'SUMMER2013', // Transaction coupon (string).
'dimension1': 'custom1',
'dimension2': 'custom2'
});
I mean if custom dimension can be set here within the setAction or not?
Thanks for your help.
Custom dimensions are set either in hit scope (referring to individual actions), product scope (with Enhanced E-Commcerce, so to speak a special case of hit scope), session scope (i.e. referring to all pageview within a visit) or user scope (referring to all sessions of a recurring user).
There is no "setAction"-scope or anything like it. I haven't tested the code and it might even work by accident, but even so it would still end up in hit/session/user scope, depending on the backend settings for your dimensions and thus would be pointless.
On our online shopping cart, some products are not being attributed to the "Product Revenue" metric in Google Analytics. I understand that if a product is not assigned to a product category, it will be counted under "Revenue" but not "Product Revenue". In this case, it appears that the products are indeed assigned properly:
_gaq.push(['sec._addTrans',
'91195800', // transaction ID - required
'nature', // affiliation or store name
'81.01', // total - required
'0', // tax
'0', // shipping
'Stoney Creek', // city
'ON', // state or province
'CA' // country
_gaq.push(['sec._addItem',
'91195800', // transaction ID - required
'ADULT - ADV', // SKU/code - required
'Product A', // product name
'Attraction Pass',
'49.946902654867', // unit price - required
'1' // quantity - required
]);
_gaq.push(['sec._addItem',
'91195800', // transaction ID - required
'UNKNOWN', // SKU/code - required
'Product B', // product name
'Attraction Pass',
'6.9911504424779', // unit price - required
'1' // quantity - required
]);
_gaq.push(['sec._addItem',
'91195800', // transaction ID - required
'ADULT - ADV', // SKU/code - required
'Product C', // product name
'Attraction Pass',
'14.752212389381', // unit price - required
'1' // quantity - required
]);
I realize there is a second error here in that the unit prices do not include tax, where the total transaction value does, so our two totals won't match there. But the difference right now is far more than just the tax.
For example, yesterday we are seeing $3,299.54 in Product Revenue but $3,932.79 in Revenue. The tax difference would only be $428.94. These are all ticket goods so no shipping costs involved.
I can actually find some of these transactions in our shopping cart backend, where I see 4 x Product A, 4 x Product B in a transaction, but Google Analytics is showing only 4 x Product A for that transaction. The Revenue metric is correct, but the Product Revenue is wrong--clicking into the transaction the Product B's are just missing.
I obviously can't go back in time to check the source code when that customer checked out, but the code above is from a test today. Unfortunately the transaction has yet to show up in GA to see what was counted and what wasn't, but is there something in that code there that would cause an issue?
Edit: The transaction is now showing in Google Analytics and I can confirm that in the above code, Product A did not get counted as an actual product. Does it matter that the SKU is the same between those two items in the code? Would that cause GA to overwrite Product A with Product C because of the same SKU?
Figured this out. SKUs must be unique. So, in my example, the third product is overwriting the first product in this transaction.
I want to use google analytice ecommerce for some requirements.
So, I used the following code snippet from google.
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'1234', // order ID - required
'Womens Apparel', // affiliation or store name
'28.28', // total - required
'1.29', // tax
'15.00', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
]);
_gaq.push(['_addItem',
'1234', // order ID - necessary to associate item with transaction
'DD44', // SKU/code - required
'T-Shirt', // product name
'Olive Medium', // category or variation
'11.99', // unit price - required
'1' // quantity - required
]);
_gaq.push(['_trackTrans']);
So with this code sample my transactions are getting tracked.
But in my google analytics profile, I'm not seeing the city, state, country. Though other details like order_id, shipping, etc SKU are getting tracked.
Please let me know if you have any idea on this.
Thanks,
Uttam
All other variables within the addTrans method are optional.
The affiliate field is not required, and was removed from the Google
Analytics Ecommerce reports. You can still use the affiliate field for
custom reports and filtering.
Tax and shipping appear in the transactions report if you have access
to those variables.
The city, state, and country are currently not being used by Google
Analytics, but the information is still being collected. You can
however use these fields within the profile filters if you have a use
for them.
Source: http://www.roirevolution.com/blog/2009/05/stressing_about_your_ga_ecommerce.php