Enhanced Ecommerce Product List Attribution - google-analytics

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

Related

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:

How do I loop through products when tracking orders with Google Analytics Ecommerce?

I have a web shop for which I want to track orders. I have successfully set up Google Analytics and pulled test data when orders are finalized, so I get information about the transaction and about the product ordered.
Naturally, I want to pull data from several products in an order, and here is where my problem arises. Whenever I insert a loop I get a template error:
Too many characters in character literal
The script I am using is this:
<script>
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '#GetString("Ecom:Order.ID")',
'affiliation': 'Online Store',
'revenue': '#GetDouble("Ecom:Order.Price.PriceWithVAT")',
'shipping': '#GetDouble("Ecom:Order.ShippingFee.Price")',
'tax': '#GetDouble("Ecom:Order.Price.VAT")'
});
#foreach(LoopItem orderline in GetLoop("OrderLines")) {
ga('ecommerce:addItem', {
'id': '#orderline.GetString("Ecom:Product.ID")',
'name': '#orderline.GetString("Ecom:Order:OrderLine.ProductName")',
'price': '#orderline.GetDouble("Ecom:Order:OrderLine.UnitPrice.Price")',
'quantity': '#orderline.GetString("Ecom:Order:OrderLine.Quantity")'
});
}
ga('ecommerce:send');
</script>
Is there something wrong in the way I use this script? It seems like there is only an error when I try to loop through products.
For anyone encountering this - my problem was that I had added the product ID in the ecommerce:addItem when instead I should have added the Order ID from ecommerce:addTransaction so it can link the products to the transaction. If you want to add the product ID, use 'sku' : [product id].

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.

Do I always need to send full product data to Google Analytics Enhanced Ecommerce?

When I send the full product data to Google Analytics in the first event E1, do I still need to send compete product data in subsequent events E2, E3,... related to that product?
So, to be more concrete, let's say I send following product data to Google Analytics when the user sees the product on the page (product impression):
ga('ec:addImpression', {
'id': 'P12345', // Product ID (string).
'name': 'Android Warhol T-Shirt', // Product name (string).
'category': 'Apparel/T-Shirts', // Product category (string).
'brand': 'Google', // Product brand (string).
'variant': 'Black', // Product variant (string).
'list': 'Search Results', // Product list (string).
'position': 1, // Product position (number).
});
Now what will happen if I only send product id in subsequent events related to that product:
ga('ec:addProduct', {
'id': 'P12345'
});
Will Google Analytics find the product data created by the impression by product ID and "join" the product data? Or those two events will be connected to two separate products and the second event will be missing all the product data (e.g. I won't be able to filter that event by product category)?
Is that behaviour documented anywhere in Google Analytics documentation?

Google Analytics Enhanced Ecommerce - How to track cart quantity update?

Google doesn't say a word on how to deal with the user changing the quantity of a line in their cart using the Enhanced Ecommerce plugin.
When a user adds something to his cart, returns to the same cart in a later session and adds more of the same product it might occur that he gets a lower unit price (for example when price breaks are used by the e-commerce site).
So, for example, he first adds 1 unit for $3, comes back and raises the number to 10 and thereby only has to pay $2 for each unit.
Now the price previously sent to GA needs to be invalidated in some way.
There are multiple solutions for this, but each of them have some serious drawbacks:
1) Calculate the difference and add / remove that.
2) Remove the line and then add with current quantity.
Method 1 has the advantage of passing the (most) correct user interaction. Since add/remove doesn't seem to have a nonInteraction parameter, using method 2 would mean wrong numbers of adds/removes.
Method 2 has the advantage of being able to change the price if a price change has happened after the product has been added the first time. For example: after adding more units the customer now has a lower unit price. Using method 1 would mean that either the amounts in GA are incorrect, or you would have to calculate price differences and fictionally give the latest added units a lower price.
Which of the two methods is preferable?
In a pure analytics.js implementation you do use
ga('ec:setAction', 'remove');
along with the product attributes describing the product being removed
see https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
// describes the product being removed
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'category': product.category,
'brand': product.brand,
'variant': product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove'); // notice 'remove' here
ga('send', 'event', 'UX', 'click', 'removed from cart'); // sends the action
If you are using GTM and GA native tags in GTM, see https://developers.google.com/tag-manager/enhanced-ecommerce#add and the remove section
// 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
}]
}
}
});
eCommerce datalayer need to be piggy-backed on other GA hits. So every time someone add or remove item, you must:
First update or rebuild * the eCommerce datalayer.
Trigger an event to pass the new data to GA.
Reset the dataLayer value to make sure you don't duplicate the data.
* Datalayer are persistent, so make sure you reset the values (dataLayer.push({'ecommerce': undefined});) after you send the data so you won't have duplicate data.
Increasing the quantity shouldn't differ than adding a product to cart. The price change case is the challenge here as you mentioned. If those transactions are not more than %5 of all transactions you may go ahead with the recent quantity and value. If you/they'd like to have the highest possibly accuracy; calculate the difference, save it to local storage, apply it as a qty-change-discount-coupon on success page.

Resources