I cannot see the purchased products in analytics e-commerce page - analytics

for my ecommerce i'm using woocommerce with GTM4WP.
I have configured Analytincs with Google Tag Manager and all data from website are correctly transfered to Analytics besides one - the ecommerce data (who purchased what product, what was the product price and so on).
I was checking website and all e
event: 'gtm.js',
gtm: {uniqueEventId: 1},
customerTotalOrders: 28,
customerTotalOrderValue: '15.30',
customerFirstName: '..',
customerLastName: '...',
customerBillingFirstName: '...',
customerBillingLastName: '...',
customerBillingCompany: '...',
customerBillingAddress1: '...',
customerBillingAddress2: '.',
customerBillingCity: '...',
customerBillingPostcode: '..',
customerBillingCountry: '...',
customerBillingEmail: '...',
customerBillingPhone: '...',
customerShippingFirstName: '..',
customerShippingLastName: '..',
customerShippingCompany: '...',
customerShippingAddress1: '...',
customerShippingAddress2: '...',
customerShippingCity: '...',
customerShippingPostcode: '...',
customerShippingCountry: '...',
cartContent: {
totals: {
applied_coupons: [],
discount_total: 0,
subtotal: '86.50',
total: '86.50'
},
items: [
{
id: 195521,
name: '....',
sku: 195521,
category: '...',
price: 21.6,
stocklevel: 112,
variant: '250g,,...',
quantity: 3
},
{
id: 195520,
name: '...',
sku: 195520,
category: '...',
price: 41.6,
stocklevel: 112,
variant: '500g,,...',
quantity: 1
}
]
},
ecomm_prodid: [195521, 195520],
ecomm_pagetype: 'cart',
ecomm_totalvalue: 106.4,
ecommerce: {
currencyCode: '...',
checkout: {
actionField: {step: 2},
products: [
{
id: 195521,
name: '...',
sku: 195521,
category: '...',
price: 21.6,
stocklevel: 112,
variant: '250g,,...',
quantity: 3
},
{
id: 195520,
name: '...',
sku: 195520,
category: '...',
price: 41.6,
stocklevel: 112,
variant: '500g,,...',
quantity: 1
}
]
}
},
google_tag_params: {
customerTotalOrders: 28,
customerTotalOrderValue: '15.30',
customerFirstName: 'P',
customerLastName: 'G',
customerBillingFirstName: '...',
customerBillingLastName: '...',
customerBillingCompany: '...',
customerBillingAddress1: '...',
customerBillingAddress2: '...',
customerBillingCity: '...',
customerBillingPostcode: '...',
customerBillingCountry: '...',
customerBillingEmail: '...',
customerBillingPhone: '...',
customerShippingFirstName: '...',
customerShippingLastName: '...',
customerShippingCompany: '...',
customerShippingAddress1: '...',
customerShippingAddress2: '...',
customerShippingCity: '...',
customerShippingPostcode: '...',
customerShippingCountry: '...',
cartContent: {
totals: {
applied_coupons: [],
discount_total: 0,
subtotal: '86.50',
total: '86.50'
},
items: [
{
id: 195521,
name: '...',
sku: 195521,
category: '...',
price: 21.6,
stocklevel: 112,
variant: '250g,,...',
quantity: 3
},
{
id: 195520,
name: '...',
sku: 195520,
category: '...',
price: 41.6,
stocklevel: 112,
variant: '500g,,...',
quantity: 1
}
]
},
ecomm_prodid: [195521, 195520],
ecomm_pagetype: 'cart',
ecomm_totalvalue: 106.4,
ecommerce: {
currencyCode: '...',
checkout: {
actionField: {step: 2},
products: [
{
id: 195521,
name: '...',
sku: 195521,
category: '...',
price: 21.6,
stocklevel: 112,
variant: '250g,,...',
quantity: 3
},
{
id: 195520,
name: '....',
sku: 195520,
category: '...',
price: 41.6,
stocklevel: 112,
variant: '500g,,...',
quantity: 1
}
]
}
}
}
}
'...' are placed instead of real data
In analytics i have enabled "ecommerce" settings.
Why i cannot see stats about purchasement in analytics?

Ilkar.
You seem to be using a mixture of Google E-Commerce and Google Enhanced E-Commerce syntax (along with some syntax that's specific to your backend system).
For example, you start your product list with 'items', which is for standard e-commerce, but use the variables 'category' and 'variant', which is for enhanced e-commerce.
Check whether or not you have enhanced ecommerce enabled.
If so, use the syntax modeled here:
https://developers.google.com/tag-manager/enhanced-ecommerce#checkout
If not, use the syntax modeled here:
https://developers.google.com/tag-manager/ecommerce-appweb#measure_a_checkout

Related

How to get a field and a field into of array in MongoDB

I have this json in MongoDB:
{
_id: ObjectId("630fbb09cc9deb16a33fbcde"),
firmness: {
name: 'hard',
url: 'https://pokeapi.co/api/v2/berry-firmness/3/'
},
flavors: [
{
flavor: {
name: 'spicy',
url: 'https://pokeapi.co/api/v2/berry-flavor/1/'
},
potency: 10
},
{
flavor: {
name: 'dry',
url: 'https://pokeapi.co/api/v2/berry-flavor/2/'
},
potency: 0
},
{
flavor: {
name: 'sweet',
url: 'https://pokeapi.co/api/v2/berry-flavor/3/'
},
potency: 0
},
{
flavor: {
name: 'bitter',
url: 'https://pokeapi.co/api/v2/berry-flavor/4/'
},
potency: 0
},
{
flavor: {
name: 'sour',
url: 'https://pokeapi.co/api/v2/berry-flavor/5/'
},
potency: 10
}
],
growth_time: 2,
id: 20,
item: { name: 'pinap-berry', url: 'https://pokeapi.co/api/v2/item/145/' },
max_harvest: 10,
name: 'pinap',
natural_gift_power: 70,
natural_gift_type: { name: 'grass', url: 'https://pokeapi.co/api/v2/type/12/' },
size: 80,
smoothness: 20,
soil_dryness: 35
}
And I want to get the soil_dryness field and the field called "name" into flavor list from 'flavors' array.
How can I do that?
I tried with:
db.Berries.find({},{soil_dryness:1},{"flavors.$":1}).pretty().limit(20)
But unfortunately doesn't works.
Query
project, the soil_dryness and the names, path in arrays = array with the values, here the names
*not sure if this the output you need, if its not if you can add the expected ouput you need
Playmongo
db.Berries.aggregate(
[{"$project": {"soil_dryness": 1, "names": "$flavors.flavor.name"}},
{"$limit": 20}])

TypeError: Cannot destructure property 'title' of 'collections' as it is undefined

I am trying to get collections using selectors. Here is my code:
Selectors
import { createSelector } from "reselect";
export const selectShop = state => state.shop;
export const selectCollections = createSelector(
[selectShop],
shop => shop.collections
)
export const selectCollectionForPreview = createSelector(
[selectCollections],
collections => Object.keys(collections).map(key => collections[key])
)
export const selectCollectionItem = collectionUrl =>
createSelector(
[selectCollections],
collections => collections[collectionUrl]
//It seems that the selector above is returning collections as an array instead of object, so collections[collectionUrl] is returning undefined
)
Component
const CollectionPage = ({collections}) => {
// const {title, items} = Object.keys(collections)
const {title, items} = collections
console.log('collection', collections);
return(
// <></>
<div className="collection-page">
<h2 className='title'>{title}</h2>
<div className='items'>
{items.map( item =>
<CollectionItem key={item.id} item={item}/>
)}
</div>
</div>
)
}
const mapStateToProps = (state,ownProps) => ({
collections: selectCollectionItem(ownProps.match.params.collectionId)(state)
})
export default connect(mapStateToProps)(CollectionPage);
SHOP_DATA
const SHOP_DATA = {
hats:{
id: 1,
title: 'Hats',
routeName: 'hats',
items: [
{
id: 1,
name: 'Brown Brim',
imageUrl: 'https://i.ibb.co/ZYW3VTp/brown-brim.png',
price: 25
},
{
id: 2,
name: 'Blue Beanie',
imageUrl: 'https://i.ibb.co/ypkgK0X/blue-beanie.png',
price: 18
},
{
id: 3,
name: 'Brown Cowboy',
imageUrl: 'https://i.ibb.co/QdJwgmp/brown-cowboy.png',
price: 35
},
{
id: 4,
name: 'Grey Brim',
imageUrl: 'https://i.ibb.co/RjBLWxB/grey-brim.png',
price: 25
},
{
id: 5,
name: 'Green Beanie',
imageUrl: 'https://i.ibb.co/YTjW3vF/green-beanie.png',
price: 18
},
{
id: 6,
name: 'Palm Tree Cap',
imageUrl: 'https://i.ibb.co/rKBDvJX/palm-tree-cap.png',
price: 14
},
{
id: 7,
name: 'Red Beanie',
imageUrl: 'https://i.ibb.co/bLB646Z/red-beanie.png',
price: 18
},
{
id: 8,
name: 'Wolf Cap',
imageUrl: 'https://i.ibb.co/1f2nWMM/wolf-cap.png',
price: 14
},
{
id: 9,
name: 'Blue Snapback',
imageUrl: 'https://i.ibb.co/X2VJP2W/blue-snapback.png',
price: 16
}
]
},
sneakers:{
id: 2,
title: 'Sneakers',
routeName: 'sneakers',
items: [
{
id: 10,
name: 'Adidas NMD',
imageUrl: 'https://i.ibb.co/0s3pdnc/adidas-nmd.png',
price: 220
},
{
id: 11,
name: 'Adidas Yeezy',
imageUrl: 'https://i.ibb.co/dJbG1cT/yeezy.png',
price: 280
},
{
id: 12,
name: 'Black Converse',
imageUrl: 'https://i.ibb.co/bPmVXyP/black-converse.png',
price: 110
},
{
id: 13,
name: 'Nike White AirForce',
imageUrl: 'https://i.ibb.co/1RcFPk0/white-nike-high-tops.png',
price: 160
},
{
id: 14,
name: 'Nike Red High Tops',
imageUrl: 'https://i.ibb.co/QcvzydB/nikes-red.png',
price: 160
},
{
id: 15,
name: 'Nike Brown High Tops',
imageUrl: 'https://i.ibb.co/fMTV342/nike-brown.png',
price: 160
},
{
id: 16,
name: 'Air Jordan Limited',
imageUrl: 'https://i.ibb.co/w4k6Ws9/nike-funky.png',
price: 190
},
{
id: 17,
name: 'Timberlands',
imageUrl: 'https://i.ibb.co/Mhh6wBg/timberlands.png',
price: 200
}
]
},
jackets:{
id: 3,
title: 'Jackets',
routeName: 'jackets',
items: [
{
id: 18,
name: 'Black Jean Shearling',
imageUrl: 'https://i.ibb.co/XzcwL5s/black-shearling.png',
price: 125
},
{
id: 19,
name: 'Blue Jean Jacket',
imageUrl: 'https://i.ibb.co/mJS6vz0/blue-jean-jacket.png',
price: 90
},
{
id: 20,
name: 'Grey Jean Jacket',
imageUrl: 'https://i.ibb.co/N71k1ML/grey-jean-jacket.png',
price: 90
},
{
id: 21,
name: 'Brown Shearling',
imageUrl: 'https://i.ibb.co/s96FpdP/brown-shearling.png',
price: 165
},
{
id: 22,
name: 'Tan Trench',
imageUrl: 'https://i.ibb.co/M6hHc3F/brown-trench.png',
price: 185
}
]
},
womens:{
id: 4,
title: 'Womens',
routeName: 'womens',
items: [
{
id: 23,
name: 'Blue Tanktop',
imageUrl: 'https://i.ibb.co/7CQVJNm/blue-tank.png',
price: 25
},
{
id: 24,
name: 'Floral Blouse',
imageUrl: 'https://i.ibb.co/4W2DGKm/floral-blouse.png',
price: 20
},
{
id: 25,
name: 'Floral Dress',
imageUrl: 'https://i.ibb.co/KV18Ysr/floral-skirt.png',
price: 80
},
{
id: 26,
name: 'Red Dots Dress',
imageUrl: 'https://i.ibb.co/N3BN1bh/red-polka-dot-dress.png',
price: 80
},
{
id: 27,
name: 'Striped Sweater',
imageUrl: 'https://i.ibb.co/KmSkMbH/striped-sweater.png',
price: 45
},
{
id: 28,
name: 'Yellow Track Suit',
imageUrl: 'https://i.ibb.co/v1cvwNf/yellow-track-suit.png',
price: 135
},
{
id: 29,
name: 'White Blouse',
imageUrl: 'https://i.ibb.co/qBcrsJg/white-vest.png',
price: 20
}
]
},
mens:{
id: 5,
title: 'Mens',
routeName: 'mens',
items: [
{
id: 30,
name: 'Camo Down Vest',
imageUrl: 'https://i.ibb.co/xJS0T3Y/camo-vest.png',
price: 325
},
{
id: 31,
name: 'Floral T-shirt',
imageUrl: 'https://i.ibb.co/qMQ75QZ/floral-shirt.png',
price: 20
},
{
id: 32,
name: 'Black & White Longsleeve',
imageUrl: 'https://i.ibb.co/55z32tw/long-sleeve.png',
price: 25
},
{
id: 33,
name: 'Pink T-shirt',
imageUrl: 'https://i.ibb.co/RvwnBL8/pink-shirt.png',
price: 25
},
{
id: 34,
name: 'Jean Long Sleeve',
imageUrl: 'https://i.ibb.co/VpW4x5t/roll-up-jean-shirt.png',
price: 40
},
{
id: 35,
name: 'Burgundy T-shirt',
imageUrl: 'https://i.ibb.co/mh3VM1f/polka-dot-shirt.png',
price: 25
}
]
}
};
export default SHOP_DATA;
Please provide any pointers or advice on what am I doing wrong? I keep getting the error. It seems that the collection is undefined. I don't understand why. Ideally it should return an object.
You are exporting the component like this
const mapStateToProps = (state,ownProps) => ({
collections: selectCollectionItem(ownProps.match.params.collectionId)(state)
})
export default connect(mapStateToProps)(CollectionPage);
The ownProps.match.params.collectionId might be undefined.
Add this at the top of your file
import { withRouter} from 'react-router-dom'
and export your component like
export default connect(mapStateToProps)(withRouter(CollectionPage));

How to get transform from object to specific key value pair using lodash?

Products: [
{_id: 'xx1', name: 'p1', sku: 's1'},
{_id: 'xx2', name: 'p2', sku: 's2'},
{_id: 'xx3', name: 'p3', sku: 's3'}
]
I want to replace word '_id' with 'product', and to map to below result:
productArray = [ {product: 'xx1'}, {product: 'xx2'}, {product: 'xx3'} ];
I tried lodash code something like below but it just doesn't seem to work correctly:
let productArray = _.map(Products, '_id');
Can anyone help me on this? Thank you
Why would you even need to use lodash? Map will easily do the job.
const products = [{
_id: 'xx1',
name: 'p1',
sku: 's1'
},
{
_id: 'xx2',
name: 'p2',
sku: 's2'
},
{
_id: 'xx3',
name: 'p3',
sku: 's3'
}
];
const outProducts = products.map(x => {
return {
product: x._id
}
});
console.log(outProducts);

How can i sort the list and print in react?

How can i sort the data and print in react.
which libraries do i need to use ?
here is the data which is to be sorted field wise
data = [{
key: 1,
name: 'Steve',
city: 'Paris',
}, {
key: 2,
name: 'Tim',
city: 'London',
}, {
key: 3,
name: 'Stella',
city: 'Bankok',
}, {
key: 4,
name: 'John',
city: 'Paris',
}];
Use Array.prototype.sort() for this.
Check this example:
data = [{
key: 1,
name: 'Steve',
city: 'Paris',
}, {
key: 2,
name: 'Tim',
city: 'London',
}, {
key: 3,
name: 'Stella',
city: 'Bankok',
}, {
key: 4,
name: 'John',
city: 'Paris',
}];
data.sort((a,b) => a.name > b.name);
console.log('updated data', data)

Provide hints to user while searching

I am stuck on the functionality to show user hints while searching of products in application.I do have an Api which returns me all category-Listing with its sub-categories/child.I have save it in my local storage but i am really confused that how can i make loop to display characters in hint list just below the search bar while user is typing something in search bar.I know the process but do not know how to implement in all nested child for every category.
I have found this below mentioned example but again its working for only simple Array ..
Example :- http://codepen.io/calendee/pen/pCwyx
Can any one suggest me that how can i use the above logic for my array
[
{
id: "165",
title: "Women's Fashion",
url: "womens-fashion",
children: [
{
id: "176",
title: "Women's Aparel",
url: "women-s-aparel",
children: [
{
id: "221",
title: "Formal",
url: "formal"
},
{
id: "222",
title: "Casual",
url: "casual"
},
{
id: "223",
title: "Traditional",
url: "traditional"
},
{
id: "224",
title: "Nightwears",
url: "nightwears"
},
{
id: "225",
title: "Winter wears",
url: "winter-wears"
},
{
id: "240",
title: "Party Wear",
url: "party-wear"
}
]
},
{
id: "220",
title: "Western Wear",
url: "western-wear",
children: [
{
id: "318",
title: "Glam & Luxe Style Wears",
url: "glam-luxe-style-wears"
},
{
id: "412",
title: "Dresses",
url: "dresses"
},
{
id: "413",
title: "Tops & Tees",
url: "tops-tees"
},
{
id: "414",
title: "Bottom Wear",
url: "bottom-wear"
}
]
},
{
id: "305",
title: "Ethnic Wear",
url: "ethnic-wear",
children: [
{
id: "407",
title: "Sarees",
url: "sarees"
},
{
id: "408",
title: "Lehnga Choli",
url: "lehnga-choli"
},
{
id: "409",
title: "Gown",
url: "gown"
},
{
id: "410",
title: "Salwar Kameez & Churidar",
url: "salwar-kameez-churidar"
},
{
id: "411",
title: "Kurtis",
url: "kurtis"
}
]
},
{
id: "306",
title: "Jewellery",
url: "jewellery",
children: [
{
id: "307",
title: "Anklets",
url: "anklets"
},
{
id: "308",
title: "Bridal Set",
url: "bridal-set"
},
{
id: "309",
title: "Mala",
url: "mala"
},
{
id: "310",
title: "Mangalsutra",
url: "mangalsutra"
},
{
id: "311",
title: "Necklace Set",
url: "necklace-set"
},
{
id: "312",
title: "Ring",
url: "ring"
},
{
id: "316",
title: "Bangles",
url: "bangles"
},
{
id: "317",
title: "Earings",
url: "earings"
}
]
},
{
id: "415",
title: "Leggings & Jeggings",
url: "leggings-and-jeggings"
},
{
id: "416",
title: "Lingeries & Nightwears",
url: "lingeries-and-nightwears"
},
{
id: "417",
title: "All Women Clothing",
url: "all-women-clothing"
}
]
},
{
id: "404",
title: "Men's Fashion",
url: "mens-fashion",
children: [
{
id: "177",
title: "Men's Aparel",
url: "men-s-aparel",
children: [
{
id: "226",
title: "Casual",
url: "casual"
},
{
id: "227",
title: "Formal",
url: "formal"
},
{
id: "230",
title: "Others",
url: "others"
},
{
id: "303",
title: "Winter",
url: "winter"
},
{
id: "239",
title: "Party Wear",
url: "party-wear"
}
]
},
{
id: "229",
title: "Ethnic",
url: "ethnic",
children: [
{
id: "418",
title: "Indo Western",
url: "indo-western"
},
{
id: "419",
title: "Kurta Pyjama",
url: "kurta-pyjama"
},
{
id: "420",
title: "Kurta",
url: "kurta"
},
{
id: "421",
title: "Sherwanis",
url: "sherwanis"
}
]
},
{
id: "228",
title: "Western",
url: "western",
children: [
{
id: "422",
title: "Jeans",
url: "jeans"
},
{
id: "423",
title: "Polo & Tees",
url: "polo-tees"
},
{
id: "424",
title: "Shirts",
url: "shirts"
},
{
id: "425",
title: "Trousers",
url: "trousers"
},
{
id: "426",
title: "Shorts & 3/4",
url: "shorts-and-3-4"
}
]
},
{
id: "427",
title: "Inner wear",
url: "inner-wear"
},
{
id: "428",
title: "Sleep & Lounge Wear",
url: "sleep-and-lounge-wear"
},
{
id: "429",
title: "Knit Wear",
url: "knit-wear"
},
{
id: "430",
title: "Suits & Blazers",
url: "suits-and-blazers"
},
{
id: "431",
title: "Sweat Shirts",
url: "sweat-shirts"
}
]
}
]

Resources