Enhnaced ecommerce google analytics code for add to cart - google-analytics

This is code for add to cart in enhanced ecommerce 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();
This is reflected in Conversions-->Ecommerce-->Product performace's Add to cart metrics.
Please see attached image.
Here i am setting default value of quantity to 40 but still 'Products Add to cart' metrics only increments it by 1 in google analytics.
Just to confirm that 40 quantity is sent or not i checked from developers tool and quantity is sent 40 only but still in google analytics 'Products Add to cart' metrics only increments it by 1 in google analytics.

Yes, I confirm that that column indicates the number of times the product was added to the shopping cart, not the quantity of product added to the cart. You can find the quantity in Summary tab of the same report.

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).

Google Analytics Enhanced Ecommerce removed basket items not shown in dashboard

I have a function to remove an item from my analytics data. I'm calling the below function, when my shopper deletes an item from their cart. I've followed the example in the docs.
function removeFromCart(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove from cart');
}
I was expecting the Product Adds To Basket metric to decrement by 1 when this function is called, but it appears to remain the same.
Is this a wrong assumption? Is there a Product Removes From Basket column that I need to reveal in the dashboard?
You can find this information in this report in Google Analytics:

Tracking with Google Tag Manager Ecommerce to Analytics

I need your help about GTM and UA.
Like this exemple i catch the Event in Google Analytics that's work fine :
// Measure the removal of a product from a shopping cart.
dataLayer.push({
'event': 'removeFromCart',
'ecommerce': {
'remove': { // 'remove' actionFieldObject measures.
'products': [{ // removing a product to a shopping cart.
'name': 'Triblend Android T-Shirt',
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1
}]
}
}
});
In Analytics i can catch the "Event" but where is products data ?
Thanks in advance for your help.
The products data is in the datalayer. You can set set the GA tag to read the dataLayer (alternatively you can set it to use an E-commerce-Variable containing the product data). This is just not very visible in the documentation, you need to click the little green arrow below the code example to expand the description of how to configure your tag (the example assumes you are using and event to send e-commerce data):
If you use a GA setting variable you might need to click "override settings" in the GA tag first.

GA Enhance Ecommerce Product List Performance

I'm using Enhanced Ecommerce and I want to know how good my product lists perform. Below a screenshot of the product list performance section.
You can see that I've set up three lists:
productgroep default (Standard product listing)
productgroep filtered (Product listing with filters used)
detail view (this is actually a product detail page, so no listing.)
There is also a:
(not set) product list name, this one comes by default.
Now when I click on a product in a list, it counts in the column Product List Clicks, all fine.
One can also add a product directly to the cart when the list is shown, so these are also measured and shown in the column Product Adds To Card.
Now when the product is purchased, it counts the Product Checkouts, Unique Purchases and Product Revenue in the product List (not set).
When the product is added to the cart directly from a list, I also do:
ga("ec:setAction", "click", {
"list": "productgroep default"
});
Why doesn't GA add these purchases to the correct product list?
When product is clicked from list page, do:
ga('ec:addProduct', {
'id': id,
'name': name,
'category': 'Apparel',
'brand': 'Nike',
'variant': 'black',
'position': 1
});
ga('ec:setAction', 'click', {list: listName});
ga('send', 'event', 'UX', 'click', 'Results');
When the product is added to the cart directly from a list, do:
ga('ec:addProduct', {
'id': id,
'name': name,
'category': 'Apparel',
'brand': 'Nike',
'variant': 'black',
'position': 1
});
ga('ec:setAction', 'click', {list: listName});
ga('send', 'event', 'UX', 'click', 'Add to Cart Catalog');
On product details page load, do :
ga('ec:addProduct', {
'id': id,
'name': name,
'category': 'Apparel',
'brand': 'Nike',
'variant': 'black'
});
ga('ec:setAction', 'detail');
ga('send', 'pageview');
The attribution in the enhanced eCommerce is a little trick, it makes list attribution and promotion attribution.
Relate to the list attribution, the purchase is recursively attributed to the last list viewed that contains the id of the product. So, even if you access the cart through one page, f you open another page that contains the product id before making the purchase, the attribution will change. With the promotion attribution is kind of different, the purchase is attributed to the last promotion clicked.
Make sure of the structure of the enhanced eCommerce object as well.
There's a full explanation here. This blog has a lot of information about it.

Enhanced Ecommerce Product List Attribution

So I have read over the Product List Attribution, and can not really understand why my addToCart, checkout and purchase data is not coming through in the product list performance reports in GA.
Product Attribution
In Enhanced Ecommerce, the Product List Performance report includes
useful Product Attribution data. The report includes a "last action"
attribute which gives product level credit to the last Product List
(i.e. add to cart, checkout, or purchase) that the user interacted
with prior to the conversion event.
Product Attribution data helps you understand which Product Lists are
driving conversions and allows you to optimize your merchandising
efforts and drive sales. For example, you can now understand whether
users are purchasing a product as a result of clicking on a
merchandising block, category page, or on the search results page.
To get started with Product Attribution, make sure to specify the list
attribute on your ecommerce action data. This list field will be used
to then attribute Product Adds To Cart, Product Checkouts, Unique
Purchases, and Product Revenue in the Product List Performance report
accordingly
I'm implementing this in GTM. I'm trying to track each one of my category pages performance however, I would like to track the Product List through the whole checkout process "Product Adds To Cart, Product Checkouts, Unique Purchases, and Product Revenue"
Does this mean I will have to assign the product list value for each product on checkout event & purchase events? if so how do you recommend I do this.
For example if a person views a product on category A, clicks a product and then continues through the addToCart checkout and purchase do I need to record that it was product list A that lead to the addToCart, checkout and purchase at each step???
So far i managed to get the list populated all the way up to Unique Purchases ( this column still gets dumped into "not set" for some reason )
For the add2cart i m using:
ga('ec:addProduct', {
'id': id,
'name': name,
'category': category,
'price': price,
'quantity': qty });
ga('ec:setAction', 'add', { 'list': category });
ga('send', 'event', 'UX', 'click', 'add to cart');
The same goes for the checkout procces ( my checkout is a onestep checkout in magento ) so i only load the page once and used :
for(var i = 0; i < cart.length; i++) {
var product = cart[i];
ga('ec:addProduct', {
'id': product.sku,
'name': product.name,
'category': product.category,
'price': product.price,
'quantity': product.qty
}); }
ga('ec:setAction','checkout', {'step': 1 , 'option': log});
ga('send', 'pageview');
Maybe you have an ideea for the last step :)
Hope this helps
You do have to add the list ID and position on the checkout flow, but not when adding a product to the cart or removing one.
You need the list ID and position for:
product impression or clicks
checkout steps
transactions
When you track the checkout steps, your code should look like this:
for(var i = 0; i < cart.length; i++) {
var product = cart[i];
ga('ec:addProduct', {
'id': product.sku,
'name': product.name,
'category': product.category,
'price': product.price,
'quantity': product.qty,
'list': product.category,
'position': product.positionInCategory
});
}
ga('ec:setAction','checkout', {'step': 1 , 'option': log});
ga('send', 'pageview');
This way, Google will associate the checkout step to the proper list.
Make sure you add the list ID and position also with when tracking the transaction itself, for every product in the transaction.
To store this between pages, I would suggest you cache the information:
on the backend side and store it in a caching database like Redis OR
on the frontend side, with cookies or local storate
directly on Google Analytics, through the Management API: https://developers.google.com/analytics/solutions/data-import-product

Resources