Update Product Data in Analytics Ecommerce reports - google-analytics

Some time ago I have implemented Google Analytics Advanced Ecommerce using GTM DataLayer.
After year of usage we have decided to change Naming of products and Added categories/brands for each transaction, also was changed all SKU/ID.
But nothing changed in reports. Names of all old products still remains old, no Brand/Category included in reports.
How can I update Product Data in reports and add categories/brands?
Thanks!
PS New products seems to be OK, but also no Category/Brand.
Here is example of DataLayer:
// Product Details
dataLayer.push({
'ecommerce': {
'currencyCode': 'EUR',
'detail': {
'products': [{
'name': 'Tetris', // Name or ID is required.
'id': 'g395',
'sku': 'g395',
'category': 'Toys & Games',
'brand': 'Mojo-jojo!'
}]
}
}
});
//// Transaction
dataLayer.push({
"ecommerce": {
"currencyCode": "EUR",
"checkout": {
"actionField": {
"step": 4
}
},
"purchase": {
"actionField": {
"id": 13202,
"affiliation": "www.mojo-jojo.com",
"revenue": 0.01
},
"products": [{
"id": "g105",
"sku": "g105",
"name": "Duracell AA",
"brand": "Mojo-jojo!",
"category": "Accessories",
"price": 0.7,
"quantity": 1
}]
}
},
"transactionId": 13202,
"transactionTotal": 0.01,
"transactionProducts": [{
"id": "g105",
"sku": "g105",
"name": "Duracell AA",
"brand": "Mojo-jojo!",
"category": "Accessories",
"price": 0.7,
"quantity": 1
}],
"event": "transaction",
"product_ids": [105],
"num_items": 1,
"conversion_value": 0.01
});

Google analytics data is read only. As soon as the data is inserted you can not change it / updated.
However now that you have changed it any data being inserted from now on will contain the new names.

Related

Exclude certain page path from count of active users GA4 API

I want to fetch count of active users on my website from GA4 API, but I want to exclude users that visited pages with "/blog/" path in them, I can do this easily on explore section of GA4, where my metric is ActiveUsers and dimension is pagePath, then I set the filter on pagePath and exclude blog pages with Not Contain filter.
but using GA4 API, using NotExpression does not works.
https://analyticsdata.googleapis.com/v1beta/properties/$MyID:runReport
Here's my request body:
{
"dateRanges": [{ "startDate": "yesterday", "endDate": "yesterday" }],
"dimensions": [{ "name": "pagePath" }],
"metrics": [{ "name": "activeUsers" }],
"dimensionFilter": {
"notExpression": {
"filter": {
"fieldName": "pagePath",
"stringFilter": {
"matchType": "CONTAINS",
"value": "/blog/"
}
}
}
}
}

How do I query for monthly page views on a particular page using Google Analytics Data API?

Is this the right request to send? And then I guess I need to manually sum the metrics over each date in the months? I can't even get the monthly view on the google analytics UI. It only lets me look at weekly. I am using google analytics v4 property. Docs
POST https://analyticsdata.googleapis.com/v1alpha:runReport
{
"entity": { "propertyId": "XXXX" },
"dateRanges": [{ "startDate": "2020-10-01", "endDate": "<today>" }],
"dimensions": [{ "name": "date" }],
"metrics": [{ "name": "eventCount" }],
"dimensionFilter": {
"andGroup": {
"expressions": [
{
"filter": {
"fieldName": "eventName",
"stringFilter": {
"value": "page_view"
}
}
},
{
"filter": {
"fieldName": "unifiedPageScreen",
"stringFilter": {
"value": "www.mysite.com/page_of_interest"
}
}
}
]
}
},
}
How is unifiedPageScreen populated on the page_view event? Do I need to do that manually?

How to access the next list of results in Here Maps API PlacesResponse?

I've been using the Herepy package for using the Here Maps API on python and I finally managed to get some of the results. I'm having a hard time accessing the next page of results in the PlacesResponse I got.
Code:
response = geocoderApi.onebox_search([12.8797, 121.7740], 'mall')
Result:
{'results': {'next': 'https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?at=12.8797%2C121.774&q=mall','items': [{'position': [12.57726, 122.26888],
'distance': 63341,
'title': 'Romblon Shopping Center',
'averageRating': 0.0,
'category': {'id': 'mall',
'title': 'Shopping Centre',
'href': 'https://places.ls.hereapi.com/places/v1/categories/places/mall',
'type': 'urn:nlp-types:category',
'system': 'places'},
'icon': 'https://download.vcdn.data.here.com/p/d/places2/icons/categories/09.icon',
'vicinity': 'Bagacay, Romblon<br/>Philippines',
'having': [],
'type': 'urn:nlp-types:place',
'href': 'https://places.ls.hereapi.com/places/v1/places/608jx7ps-e037893cbff505fbef78dc1294497c1d;context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmcmFuaz0w',
'id': '608jx7ps-e037893cbff505fbef78dc1294497c1d'}
...
I tried accessing the next link by adding my API Key on the request but I can't seem to get the next list of results.
next_results = requests.get('https://places.ls.hereapi.com/places/v1/discover/search?apiKey={API_KEY_HERE};context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?at=12.8797%2C121.774&q=mall')
https://places.ls.hereapi.com/places/v1/discover/search?apiKey={API_KEY_HERE};context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?at=12.8797,121.774&q=mall
Your next url is malformed. The apiKey should be along with the other query string parameters at and q:
https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?apiKey=API_KEY_HERE&at=12.8797,121.774&q=mall
With a properly formed next url, I get the following response for the coordinates you used and the mall search word:
{
"previous": "https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD01NWRiOTk5NC0zM2ZmLTUwMjctOWRmOC01MmE5YzMyZmJhM2RfMTU3OTI1OTczODg3NF84MjYxXzE3NDQmb2Zmc2V0PTAmc2l6ZT0yMA?at=12.8797%2C121.774&q=mall",
"next": "https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD01NWRiOTk5NC0zM2ZmLTUwMjctOWRmOC01MmE5YzMyZmJhM2RfMTU3OTI1OTczODg3NF84MjYxXzE3NDQmb2Zmc2V0PTQwJnNpemU9MjA?at=12.8797%2C121.774&q=mall",
"offset": 20,
"items": [
{
"position": [
11.962863,
121.925928
],
"distance": 103274,
"title": "Mit",
"averageRating": 0.0,
"category": {
"id": "mall",
"title": "Shopping Centre",
"href": "https://places.ls.hereapi.com/places/v1/categories/places/mall",
"type": "urn:nlp-types:category",
"system": "places"
},
"icon": "https://download.vcdn.data.here.com/p/d/places2/icons/categories/09.icon",
"vicinity": "Balabag, Malay, 5608<br/>Philippines",
"having": [],
"type": "urn:nlp-types:place",
"href": "https://places.ls.hereapi.com/places/v1/places/608wdnsn-d3edd5c804da4698bc913e04da8ca891;context=Zmxvdy1pZD01NWRiOTk5NC0zM2ZmLTUwMjctOWRmOC01MmE5YzMyZmJhM2RfMTU3OTI1OTczODg3NF84MjYxXzE3NDQmcmFuaz0yMA",
"id": "608wdnsn-d3edd5c804da4698bc913e04da8ca891"
},
...
]
}

gtag.js can't correctly send Enhanced eCommerce event to google analytics

I use the gtag.js to send Enhanced eCommerce event to Google Analytics. I think Google Analytics actually gets all event from my demo web. But there are 3 type event was not shown at event table.
and the 3 events below:
Measure product impressions
Measure product detail views
Measure promotion impressions
And here is the sample code I used:
Measure product impressions
gtag('event', 'view_item_list', {
"items": [
{
"id": "P12345",
"name": "Android Warhol T-Shirt",
"list_name": "Search Results",
"brand": "Google",
"category": "Apparel/T-Shirts",
"variant": "Black",
"list_position": 1,
"quantity": 2,
"price": 2
},
{
"id": "P67890",
"name": "Flame challenge TShirt",
"list_name": "Search Results",
"brand": "MyBrand",
"category": "Apparel/T-Shirts",
"variant": "Red",
"list_position": 2,
"quantity": 1,
"price": 3
}
]
});
Measure product detail views
gtag('event', 'view_item', {
"items": [
{
"id": "P12345",
"name": "Android Warhol T-Shirt",
"list_name": "Search Results",
"brand": "Google",
"category": "Apparel/T-Shirts",
"variant": "Black",
"list_position": 1,
"quantity": 2,
"price": '2.0'
}
]
});
Measure promotion impressions
gtag('event', 'view_promotion', {
"promotions": [
{
"id": "abc123",
"name": "summer_promo"
},
{
"id": "xyz987",
"name": "spring savings"
}
]
});
I find that the commonality of these events is that they are all page load event. But I use click to trigger them. But I think it's also have to work.
That's so strange~ Somebody help me, please~

How to update/change an order in google analytics

So I've been fiddling with this for a while now and I can't wrap my head around how analytics does it's calculations on purchases when updating an order with new/changed products.
I'm utilizing the datalayer(dl) and push my purchase event to the dl, which GTM listens to via a trigger event, all standard so far.
{
"event": "purchase",
"currencyCode": "SEK",
"ecommerce": {
"purchase": {
"actionField": {
"id": "123",
"tax": 30.0,
"action": "purchase"
},
"products": [
{
"name": "name",
"id": "123",
"price": "5.0",
"brand": "brand",
"category": "category",
"quantity": 2
}
]
}
}
}
But then our customers has the ability to change their orders. So with a bit of research On here I was able to defer that you can add products with a negative quantity on the existing order to remove products after a changed order.
So this resulted in, something not optimal but it works for the orders products atleast. In this case I want one more item of the same. So I do this:
{
"event": "purchase",
"currencyCode": "SEK",
"ecommerce": {
"purchase": {
"actionField": {
"id": "123",
"tax": newTax -= oldTax,
"action": "purchase"
},
"products": [
{
"name": "name",
"id": "123",
"price": "5.0",
"brand": "brand",
"category": "category",
"quantity": 3
},
{
"name": "name",
"id": "123",
"price": "5.0",
"brand": "brand",
"category": "category",
"quantity": -2
}
]
}
}
}
And it works for everything except the total of the purchase. Since that's calculated based on the products in the order why doesn't that update automatically when I update the order? Do I need to send in the oldTotal -= newTotal as well or is there a delay in the recalculations in analytics?
Instead of letting it calculate the total revenue on its own, have you tried adding the total revenue, total tax and total shipping on your own. These fields are present in the actionField as follows:-
"actionField": {
"id": "123",
"action": "purchase"
'revenue': 'newRev - oldRev', // difference of new revenue and old revenue
'tax':'newTax - oldTax', // difference of new tax and old tax
'shipping': 'newShipping - oldShipping' // difference of new shipping and old shipping
},
Of course do add the products as well.
In the canned GA reports, it will automatically add the old revenue and the new revenue amounts and use that as the revenue total.

Resources