Google Enhanced E-Commerce Tracking not working - google-analytics

I tried the follwoing code
ga('create', 'UA-111563164-2', 'auto');
ga('require', 'ec');
ga('ec:addImpression', { // Provide product details in an impressionFieldObject.
'id': 'trip-to-fairy-meadows-and-nanga-parbat-base-camp-by-directions-explore-with-us', // Product ID (string).
'name': 'TRIP TO FAIRY MEADOWS AND NANGA PARBAT BASE CAMP', // Product name (string).
'brand': 'DIRECTIONS - EXPLORE WITH US', // Product brand (string). // Product variant (string).
'category': 'Apparel/T-Shirts',
'variant': 'black',
'list': 'Search Results',
'position': 1
});
ga('ec:addImpression', {
'id': 'P67890',
'name': 'YouTube Organic T-Shirt',
'category': 'Apparel/T-Shirts',
'brand': 'YouTube',
'variant': 'gray',
'list': 'Search Results',
'position': 2
});
ga('send', 'pageview');
The code is written in angular 4 and i am using angulartics2 library. the data is not push toward to the google analytics.

Your code looks fine and should work as intended. The reason you are not seeing any data is likely because Google Analytics data processing latency.
Processing latency is 24-48 hours. Standard accounts that send more than 200,000 sessions per day to Analytics will result in the reports being refreshed only once a day. This can delay updates to reports and metrics for up to two days. To restore intra-day processing, reduce the number of sessions your account sends to < 200,000 per day.
For Analytics 360 accounts, this limit is extended to 2 billion hits per month.
More in Google Analytics official documentation: https://support.google.com/analytics/answer/1070983?hl=en

Related

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.

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.

Revenue always zero for addtransaction

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');

setting ecommerce values for Google Analytics when using Tag Manager

I just switched over to using Google Tag Manager so everything is mostly in one place. I have to say I love it so far, but I think I have a problem with the analytics ecommerce values.
In Google's documentation they show this as an example as per doc using the dataLayer :
<script>
dataLayer = [{
'transactionId': '1234',
'transactionAffiliation': 'Acme Clothing',
'transactionTotal': 38.26,
'transactionTax': 1.29,
'transactionShipping': 5,
'transactionProducts': [{
'sku': 'DD44',
'name': 'T-Shirt',
'category': 'Apparel',
'price': 11.99,
'quantity': 1
},{
'sku': 'AA1243544',
'name': 'Socks',
'category': 'Apparel',
'price': 9.99,
'quantity': 2
}]
}];
</script>
The above is what I followed. Using Tag Assistant plugin for Chrome shows everything working fine and the values come in as expected, BUT... today I have had a few sales and the data is not showing in my GA account...
I also found this page in the help doc which shows a completely different method for adding the ecommerce data with completely different values. Here they use something like this which is how I was doing it with the regular Google Analytics script (not the tag manager) :
ga('ecommerce:addTransaction', {
'id':'1234',
'affiliation':'some site',
'revenue':100.00,
'currency':'USD'
});
ga('ecommerce:addItem', {
'id': '1234',
'name': 'some product',
'sku': 'some sku',
'price': 150.00,
'quantity': 1
});
So, what is the correct method to specify these values when using the Google Tag Manager?
you are mixing two types of tracking - 1) using GTM and then 2) using the actual JavaScript in source code to send the data to GA.
I would stick with GTM, it just makes everything easier. It seems that you have everything ready in DataLayer with product names, so now you just need to create a new Tag with those attributes:
Tag Type = Google / Universal Analytics
Track Type = Transaction
add any other configuration fields you are using across your website...
Then just create a rule when to fire this tag (usually a conversion page - probably the same as your Goal URL in GA setup).
That should do the trick - if a visitor makes a purchase successfully, then after loading the conversion page, GTM will send 1 pageview reqeust and 1 transaction request (they needs to be fired separately).
Also, you might be interested in new version of E-commerce tracking, named Enhanced Ecommerce. It add tons of new and very useful stuff (apart from measuring transaction, it's focused on the whole process of purchasing - browsing products, adding to carts etc.). Here is the manual how to set it up using GTM. It's a bit more difficult, but worth the effort in my opinion.
Hope this helps.
For anyone interested this is what I came up with for my needs. Works fine, values are just examples of course. Sorry for the late response on this one.
//repeat for each product
myProducts.push({
'name': 'some name',
'id': 'some id',
'price': 100.00,
'category': 'some category',
'brand': 'some brand',
'quantity': 10
});
//full push for the dl
dataLayer.push({
'event': 'TrackOrderComplete',
'google_conversion_value': 100.00,
'google_conversion_currency': 'USD',
'ecommerce': {
'purchase': {
'actionField': {
'id': 'some id',
'affiliation': 'some affiliation',
'revenue': 100.00,
'tax': 5.00,
'shipping': 10.00,
'coupon': 'some coupon'
},
'products': myProducts
}
}
});

Resources