Google Analytics not displaying Category - google-analytics

After much pain and weeping and gnashing of teeth, I finally managed to get my website to talk to GTM and GTM to send data to Analytics.
I can see revenue and conversion rates and transaction results in Analytics, but not the product category.
I have my GTM tag set to use the Transaction track type along with the data layer.
My test code is:
dataLayer.push({
'transactionId': 'OnClickTransactionDataLayerPushID', // Transaction ID - Type:String - Required
'transactionAffiliation': 'OnClickTransactionDataLayerPushAffiliation', // store name - Type:String - Optional to use
'transactionTotal': 45, //total revenue - Type:Numeric - Required
'transactionTax': 5, // Tax amount for transaction - Type:Numeric - Optional to use
'transactionShipping': 5, // Shipping cost - Type:Numeric - Optional to use
'transactionProducts': [{
'sku': 'SKU456789', // Product SKU - Type:String - Required
'name': 'OnClickTransactionDataLayerPushName', // Product Name - Type:String - Required
'category': 'OnClickTransactionDataLayerPushNameCategory', // Product Category - Type:String - Optional to use
'price': 35, // Product Price - Type:Numeric - Required
'quantity': 1 // Product Quantity - Type:Numeric - Required
}]
});
In the GA Debugger I can see that the category is being sent as: ec:item variation (&iv) OnClickTransactionDataLayerPushNameCategory
The only problem is that this isn't a true variation. A variation would be something like color or size, not whether an item belongs to a t-shirt category or whatever. In any event, if this information is being sent over, why can't I see it in Analytics?
EDIT
After trying the Enhanced ECommerce code again as below, I see that the product names are hitting the top products list, but no monetary amounts or quantities are displayed. I can see that being sent in the GA debugger though?
dataLayer.push({
"event": "addToCart",
"ecommerce": {
"currencyCode": "USD",
"add": {
"products": [{
"id": "b55da",
"name": "Flexigen T-Shirt",
"price": "16.00",
"brand": "Flexigen",
"category": "T-Shirts",
"variant": "red",
"dimension1": "M",
"position": 0,
"quantity": 1
}]
}
}
});

Your code is standard e-commerce and the report says enhance e-commerce.
Standard
https://support.google.com/tagmanager/answer/6107169?hl=en
Enhance
https://developers.google.com/tag-manager/enhanced-ecommerce
Disable the enhance e-commerce in you view configuration, tab e-commerce and try to look again.

Related

Ecommerce purchase value is not decreased after a refund event in GA4

I'm migrating from UA to GA4 for ecommerce tracking.
I'm testing buy-and-refund scenario with GA: I sent a purchase event to GA4 via measurement protocal; After I ensured the purchase event is received (value showed in Ecommerce Purchases), I sent a refund event with the same transaction ID (through measurement protocal as well). I waited a day, but the value of purchase values in "GA4 Monetization -> Ecommerce Purchases" didn't decrease.
I'm sure the refund event is received (from Realtime report and Explore) by GA4. Is this a bug or expected behaviour? I didn't see it is described anywhere. Did I make any mistakes in event payload?
Here are my event payloads:
{
"name": "purchase",
"params": {
"items": [
{
"item_id": "L-6",
"item_name": "Product Report - 1775",
"item_category": "Report",
"quantity": 1,
"price": 60,
"currency": "CNY"
}
],
"currency": "CNY",
"transaction_id": "LP-6",
"value": 60
}
{
"name": "refund",
"params": {
"currency": "CNY",
"transaction_id": "LP-6",
"value": 60
}
}
When I was using UA, I could send negative revenue in transaction hit and negative quality in transaction_item hit in order to refund and decrease reveune. It seems this doesn't work in GA4? Should I should negative value in refund event? I didn't see any docs about it.
As far my tests showed, GA4 just increments the metric "Refunds" by 1 after a full refund.
If you just need total number of purchases or E-commerce revenue, you could filter all the transactions that have refunds=0 and read the totals from "E-commerce revenue" or "E-commerce purchases", but I found that when you combine item-related dimensions or metrics (i.e. item name, item revenue, etc) the metric "Refunds" is showing as 0 even for refunded transactions.
Something is not quite right here.

Custom metric/dimension not visible in GA4 DebugView on item/product-list level

We're trying to configure GA4 to gather same data that we have in UA.
The problem is that we cant see custom metrics data on item-level in DebugView.
In TagAssistant we can see that data is sent:
{
event: "purchase",
gtm: {uniqueEventId: 10, start: 1651XXX},
gtag: {
targets: {
G-XXX: {_ee: true, _uei: 3, _upi: 2},
UA-XXX: {
currency: "PLN",
country: "PL",
custom_map: {
dimension2: "referrer",
...
dimension13: "ecomm_totalvalue",
metric1: "metric1",
...
metric5: "metric5"
},
_uei: 4
},
AW-106XXX: {}
}
},
eventModel: {
transaction_id: "40XXX",
affiliation: "XXX",
value: "9.99",
currency: "PLN",
tax: "1.87",
shipping: "0",
coupon: "",
items: [
{
id: "670",
name: "Tusz Zamiennik T0711 do Epson (C13T07114010) (Czarny)",
brand: "XXX",
category: "Wkłady/Atramentowe/Zamienniki/Tusze/XXX -> Do:E" +
"pson",
quantity: 1,
price: "9.99",
coupon: "",
metric1: "9.99",
metric2: "9.99",
metric3: "9.99",
metric4: "9.99",
metric5: "9.99"
}
],
send_to: ""
}
}
However, on DebugView side we can see purchase event that:
contains all orginal parameters on event level (like transaction_id, shipping etc.)
contains all orginal parameters on item level (like item_id, quantity, etc.)
But our custom metrics are missing
In the other hand, we tried (with different event) push some custom-dumension data and:
they are visible on GA4 DebugView
we can create custom dimension in GA4 basing on this data and it works
I am thinking about:
Creating event-level custom metric to test if it will be passed to GA4 DebugView
Creating item-level custom dimension to test if it will be passed to GA4 DebugView
However, due to fact that GA requires 24h to make conclusions i decided to ask here for any sugestions why it is not working and what else may i test.

How to push Ecommerce Transactions to GTM Data Layer

I'm pushing some tags to the data layer and they all seem to be working as expected except for ecommerce transaction data. I have confirmed that the transaction data is being pushed to the data layer but for some reason I'm not seeing any results in Google Analytics—even after waiting 48 hours.
I should mention that this is an SPA so there is no page refreshing. The data is pushed to the data layer after the payment is successfully processed.
This is the data I'm sending:
{
event: 'subscribe',
user: <USER_ID>,
subscribe: {
transactionId: <CUSTOMER>,
transactionAffiliation: <AFFILIATION>,
transactionTotal: <PRICE>,
transactionProducts: [
{
id: <CUSTOMER>,
sku: <SUBSCRIPTION>,
name: <PLAN>,
price: <PRICEPER>,
quantity: <QUANTITY>
}
]
}
};
Is there something wrong with the way I'm formatting this? Any ideas why this doesn't seem to be working?
For just regular NOT enchanced ecomm, you need to make some adjustments to your datalayer first:
{
event: 'subscribe',
user: <USER_ID>,
transactionId: <CUSTOMER>,
transactionAffiliation: <AFFILIATION>,
transactionTotal: <PRICE>,
transactionProducts: [{
id: <CUSTOMER>,
sku: <SUBSCRIPTION>,
name: <PLAN>,
price: <PRICEPER>,
quantity: <QUANTITY>
}]
};
Then create a custom event trigger referencing the subscribe event:
Then create a GA tag and select Track Type of Transaction, elect your GA settings variable and set the trigger to that custom event trigger we created above:

Google Analytics API Revenue Discrepances

I have discrepancies in the revenue metric, between the data I collect from the Google Analytics API and the custom reports in the user interface.
The discrepancies for each value maintain the same rate, where the data collected through the API is greater than the data in the custom reports.
This is the body of the request I'm using:
{
"reportRequests":[
{
"viewId":"xxxxxxxxxx",
"dateRanges": [{"startDate":"2017-07-01","endDate":"2018-12-31"}],
"metrics": [
{"expression": "ga:transactionRevenue","alias": "transactionRevenue","formattingType": "CURRENCY"},
{"expression": "ga:itemRevenue","alias": "itemRevenue","formattingType": "CURRENCY"},
{"expression": "ga:productRevenuePerPurchase","alias": "productRevenuePerPurchase","formattingType": "CURRENCY"}
],
"dimensions": [
{"name": "ga:channelGrouping"},
{"name": "ga:sourceMedium"},
{"name": "ga:dateHour"},
{"name": "ga:transactionId"},
{"name": "ga:keyWord"}
],
"pageSize": "10000"
}]}
This is an extract of the response:
{{
"reports": [
{
"columnHeader": {
"dimensions": [
"ga:channelGrouping",
"ga:sourceMedium",
"ga:dateHour",
"ga:transactionId",
"ga:keyWord"
],
"metricHeader": {
"metricHeaderEntries": [
{
"name": "transactionRevenue",
"type": "CURRENCY"
},
{
"name": "itemRevenue",
"type": "CURRENCY"
},
{
"name": "productRevenuePerPurchase",
"type": "CURRENCY"
}
]
}
},
"data": {
"rows": [
{
"dimensions": [
"(Other)",
"bing / (not set)",
"2018052216",
"834042319461-01",
"(not set)"
],
"metrics": [
{
"values": [
"367.675436",
"316.55053699999996",
"316.55053699999996"
]
}
]
},
...
So, if I create a custom report in the Google Analytics user interface and look for the transaction ID 834042319461-01, I get the following result:
google Analytics custom report filtered by transaction id 834042319461-01
In the end I have a revenue value of 367.675436 in the API response, but a value of 333.12 in the custom report, its a 10.37% more in the value of the API. I get this 10.37% increase for all values.
¿Why I'm having these discrepance?
¿What would you recomend to do in order to solve these problem?
Thanks.
My bet is that you're experiencing sampling (is your time range in the UI lower than in the API?): https://support.google.com/analytics/answer/2637192?hl=en
Sampling applies when:
you customize the reports
the number of sessions for the overall time range of the report (whether or not your query returns less sessions) exceeds 500K (GA) or 100M (GA 360)
The consequence is that:
the report will be based on a subset of the data (the % depends on the total number of sessions)
therefore your report data won't be as accurate as usual
What you can do to reduce sampling:
increase sample size (will only decrease sampling to a certain extend, but in most cases won't completely remove sampling). In UI it's done via the option at the top of the report, in the API it's done using the samplingLevel option
reduce time range
create filtered views so your reports contain the data you need without needed to customize reports
Because you are looking at a particular transaction ID, this might not be a sampling issue.
If the ratio is consistent, from your question it seems to be 10.37%. I believe this is the case of currency that you are using.
Try using local currency metric API calls when making monetary based calls.
For example -
ga:localTransactionRevenue instead of ga:transactionRevenue

With PayPal REST SDK, how I can I get the buyer's country but not the entire address?

I'm using the PayPal REST SDK for payments, but since I'm selling digital goods, I don't need a shipping address, so for privacy reasons I don't want one.
However, it sounds like I need the billing country for Euro VAT purposes, and I don't know how to do that.
I've configured a payment experience using the following request:
{
"flow_config": {
"landing_page_type": "Billing"
},
"input_fields": {
"allow_note": false,
"no_shipping": 1
},
"name": "my name"
}
The no_shipping parameter is documented thus:
Determines whether or not PayPal displays shipping address fields on
the experience pages. Allowed values: 0, 1, or 2. When set to 0,
PayPal displays the shipping address on the PayPal pages. When set to
1, PayPal does not display shipping address fields whatsoever. When
set to 2, if you do not pass the shipping address, PayPal obtains it
from the buyer’s account profile. For digital goods, this field is
required, and you must set it to 1.
And preparing the payment:
{
"experience_profile_id": "XP-JVB9-FJ5Y-RMWS-ZCTS",
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
etc…
}
Executing the payment returns:
{
"create_time": "2015-02-05T08:24:53Z",
"id": "PAY-snip",
"intent": "sale",
"links": [
{
"href": "snip",
"method": "GET",
"rel": "self"
}
],
"payer": {
"payer_info": {
"email": "test#test.com",
"first_name": "Test",
"last_name": "Buyer",
"payer_id": "snip"
},
"payment_method": "paypal"
},
etc…
}
Which is great: no address… but also no country code.
I think PayPal is missing another value, which requests the country code but not the rest of the address…

Resources