Can't get categorys in enhanced ecommerce - google-analytics

I'm trying to figure out how google enhanced ecommerce tracking works together with google tag manager. I have the following json I'm trying to send with ProductClickEvent:
dataLayer.push({
event: 'ProductClickEvent',
eventCategory: 'Link',
eventAction: 'Product Name',
ecommerce: {
click: {
actionField: {list: 'TopProducts', action: 'click'},
products: [
{
name: 'Product Name',
category: 'category/another category',
id: '8722095',
position: 1,
price: '5.85'
}
]
}
}
});
but when I look at the overview and click on and try to get category list (enhanced ecommerce) I get 'Not set' on all the products.
Do I have to add something to tag manager to hook this up?

Related

Mixing Tag Manager GA4 events and Google Ads hotel conversions

We currently have a hotel website which uses Tag Manager to post data into GA4. The Tag Manager embed code is included in the <head> of all pages. On the booking confirmation page there is some inline code, below, which posts generic purchase details to the data layer, from which an Analytics Tag fires in Tag Manager and the purchase event is logged in GA4. This works fine.
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'purchase',
ecommerce: {
currency: 'EUR',
value: 123.45,
tax: 0.00,
shipping: 0.00,
affiliation: 'Some Affiliation',
transaction_id: 'ID234',
coupon: '',
items: [{
item_name: 'Item 1',
item_id: 'SKU1',
price: '123.00',
item_brand: 'Our Brand',
item_category: 'Some Category',
quantity: '1'
},
{
item_name: 'Item 2',
item_id: 'SKU2',
price: '0.45',
item_brand: 'Our Brand',
item_category: 'Some Category',
quantity: '1'
}],
facebook_pixel_ecommerce_tracking: 'true',
content_name: 'Content Name',
content_ids: 222,333,444
}
});
Now we would like to use Conversion Tracking for Hotel Campaigns to log conversions in Google Ads and I'm finding it hard to understand how to do this in our implementation from that documentation.
The docs suggest calling the following code on the purchase confirmation page:
gtag('event', 'purchase', {
'send_to': [
'AW-GOOGLE_CONVERSION_ID/GOOGLE_CONVERSION_LABEL'
'transaction_id': 'BOOKING_ID',
'value': PRICE,
'currency': 'CURRENCY',
'items': [{
'id': 'PARTNER_HOTEL_ID',
'start_date': 'CHECK_IN_DATE',
'end_date': 'CHECK_OUT_DATE'
}]
});
Questions:
Am I correct in saying that both snippets of code are effectively required - the first will continue to trigger the GA4 event and the second will trigger the Ads conversion? i.e. We can't merge them into a single event?
We're using the Tag Manager embed code globally across the site, which does not give us access to gtag, so actually using the second code snippet above will error in our case. Assuming we don't want to replace our global Tag Manager embed code with a GTAG script, how can we get the second snippet to work without affecting any existing tags etc?
Many thanks.

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

How to track lead generating products

We have a website where we present our products, there is no price shown, no add-to-cart button, just photos and text.
We want to track form submissions by product. (product x => 32 form submissions, product y => 7 form submissions)
We have setup a gtag event with a goal in analytics to show us how many people used the contact form successfully with
window.gtag('event', 'submit', {
'event_category': 'form',
'event_label': 'contact_form',
'value': 1
})
I cannot find something specific for this in the google analytics events documentation
Without being too complicated, why not just reorganize your events a little.
window.gtag('event', 'submit', {
'event_category': 'contact form',
'event_label': 'product x',
'value': 1
})

GTM : Data layer AddProduct not going into to GA

I just installed an addToCart event that appears like this in the preview function of Google Tag Manager :
{
event: 'addToCart',
ecommerce: {
currencyCode: 'EUR',
add: {
products: [{
id: '6',
price: 30.5,
variant: '31',
quantity: '1'
}]
}
}
}
The problem is that nothing appears in Google Analytics eCommerce features in Product Adds.
Anyone know why? I call the function directly in the addcart.js in Prestashop.
Edit: Here is the full code:
sendToGA : function(id_product, id_combination, quantity, price){
dataLayer.push({
'event': 'addToCart',
'ecommerce': {
'currencyCode': 'EUR',
'add': {
'products': [{
'id': id_product,
'price': price,
'variant': id_combination,
'quantity': quantity
}]
}
}
});
}
The dataLayer.push() looks correct. Did you add a GA Event tag to your live container version that fires based on a custom event trigger set to "addToCart" and that is configured with the following options?
Enable Enhanced Ecommerce Features: true
Use Data Layer: true
For instructions see :https://developers.google.com/tag-manager/enhanced-ecommerce#add
Also, ga-debug is a useful Chrome plugin to see if your tag is actually sending data to GA, and what it is sending.

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