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:
Related
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.
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].
I am currently trying to send custom dimension values with the product impressions event. Everything else seems to work but I am not able to report on the custom dimension values.
I have set up dimension8 and dimension 9 for star rating and review count. I have passed through these values to the object and it is successfully being sent.
dataLayer.push({
'event': 'productDetailImpressions',
'ecommerce': {
'detail': {
'actionField': {
'list': 'PDP'
},
'products': [{
'name': name,
'id': id,
'price': price,
'brand': brand,
'category': category,
'variant': variant,
'dimension8': reviewCount,
'dimension9': starRating
}]
}
}
});
I have set these custom dimensions up with product scope in GA.
I can view the tag and the information it is sending with a plugin in the browser, the values look correct.
However I am still not able to report on these values inside Google Analytics.
Is there anything I am doing wrong?
Thank you.
The scoping of dimensions required 2 things:
Configure scope in Google Analytics admin interface
See below screenshot:
Send custom dimension with the proper hit
Data is sent to Google Analytics with "hits". Hits are:
page tracking hits
event tracking hits
ecommerce tracking hits social
interaction hits
Now this doesn't mean that you should structure your dataLayer so that the custom dimensions are on the same level ase the object (eg user, product) you're trying to associate them with. Instead, you should follow the standard method for setting dimensions:
In Google Analytics, it is:
// Set the dimension
ga('set', 'cd1', 'Level 1');
// Send custom dimension along with a hit (eg pageview)
ga('send', 'pageview');
Now with Google Tag Manager, GTM doesn't send any hits to Google Analytics, it's just a tool for preparing your data and automating the use of GA. So an example on how to do it:
dataLayer.push({
'event': 'productDetailImpressions',
'dimension8': reviewCount,
'dimension9': starRating,
'ecommerce': {
'detail': {
'actionField': {
'list': 'PDP'
},
'products': [{
'name': name,
'id': id,
'price': price,
'brand': brand,
'category': category,
'variant': variant,
}]
}
}
});
Then create some dataLayer variables to read the custom dimension values:
Finally, assign those dimensions to your GA tags:
note: you could potentially make it work with the dataLayer you have, you would just have to replace your dataLayer variable to point to the right location, however I think it's bad practice because it leads to believe that dimensions have to be nested within the scoped object in order to work (which is not true) and it makes things harder to debug.
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.
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