Google Analytics Measurement Protocol Measuring Transaction but not Product Data - google-analytics

Given the payload:
v=1
&tid=UA-REDACTED
&ds=web
&cid=REDACTED
&uid=15844
&uip=REDACTED
&ua=Mozilla%2f5.0+(Windows+NT+10.0%3b+Win64%3b+x64)+AppleWebKit%2f537.36+(KHTML%2c+like+Gecko)+Chrome%2f68.0.3440.106+Safari%2f537.36
&ul=en-gb
&dp=%2f
&dh=www.devserver.com
&t=transaction
&ti=TestTxn8TI
&tr=105
&tt=10
&ts=5
&cu=EUR
&ds=web
&pr1id=testsku
&pr1nm=test%20product%20description
&pr1ca=hardware
&pr1pr=100
&pr1qt=1
&pr2id=testsku2
&pr2nm=another%20description
&pr2ca=hardware
&pr2pr=20
&pr2qt=2
&pa=purchase
It's correctly measuring the transaction:
However no associated product data. How do I get the product data to show?

Seems to me that you're mixing Ecommerce hits, with Enhanced Ecommerce hit.
According to Measurement Protocol documentation for Enhanced Ecommerce Tracking:
Important: Enhanced Ecommerce parameters must be sent with an existing hit (e.g. pageview, event), but cannot be sent with the Ecommerce transaction or item hit types.
With that being said, to continue sending the hit under Ecommerce Tracking:
Trigger a Transaction Hit
v=1
&tid=UA-XXXXX-Y
&cid=555
&t=transaction
&ti=TestTxn8TI
&tr=105
&ts=5
&tt=10
&cu=EUR
Trigger Item Hit for each product in the transaction
v=1
&tid=UA-XXXXX-Y
&cid=555
&t=item
&ti=testsku
&in=test%20product%20description
&ip=100
&iq=1
&iv=hardware
&cu=EUR
v=1
&tid=UA-XXXXX-Y
&cid=555
&t=item
&ti=testsku2
&in=another%20description
&ip=20
&iq=2
&iv=hardware
&cu=EUR
If you're interested in sending the hit under Enhanced Ecommerce Tracking, simply change the Hit Type from transaction to pageview, like:
v=1
&tid=UA-XXXXX-Y
&cid=555
&t=pageview
&dh=www.devserver.com
&dp=%2f
&ds=web
&uid=15844
&uip=REDACTED
&ua=Mozilla%2f5.0+(Windows+NT+10.0%3b+Win64%3b+x64)+AppleWebKit%2f537.36+(KHTML%2c+like+Gecko)+Chrome%2f68.0.3440.106+Safari%2f537.36
&ul=en-gb
&ti=TestTxn8TI
&tr=105
&tt=10
&ts=5
&cu=EUR
&pa=purchase
&pr1id=testsku
&pr1nm=test%20product%20description
&pr1ca=hardware
&pr1pr=100
&pr1qt=1
&pr2id=testsku2
&pr2nm=another%20description
&pr2ca=hardware
&pr2pr=20
&pr2qt=2
Hope that helps!

Related

Google Analystics Messurement Protocol - ECommerce data does not appear

I'm posting the following payload to the Google Analytics API :
v=1
t=transaction
tid=UA-157XXXXXX-X
cid=224ac375-3797-4512-9702-fcaf2cc9fdcb
ti=OD001
in=Panton%20Chair
iq=2
ic=PC
iv=Chairs
cd1=79123
but the posted data is not showing up correctly.
The transaction is visible, but the product is not.
What am I doing wrong ?
You need to send one measurement protocol hit for the transaction, and one for each item.
For example, your first measurement protocol hit would be:
v=1
t=transaction
tid=UA-157XXXXXX-X
cid=224ac375-3797-4512-9702-fcaf2cc9fdcb
ti=OD001
tr=1234.56
cd1=79123
Then you would send a
v=1
t=item
tid=UA-157XXXXXX-X
cid=224ac375-3797-4512-9702-fcaf2cc9fdcb
ti=OD001
in=Panton%20Chair
iq=2
ic=PC
iv=Chairs
cd1=79123
See more: https://www.optimizesmart.com/sending-ecommerce-data-via-measurement-protocol-google-analytics/
Also, as a side note, it might be better to upgrade to enhance ecommerce. There you could send it in a single hit

Google Analytics Measurement Protocol and Enhanced e-commerce not capturing revenue

I'm trying to use the measurement protocol to record an offline purchase on our backend system. The problem is, after I send the Measurement Protocol request, the goal conversion is captured correctly in GA's reports, but the revenue earned from the purchase is always displayed as 0.00 in the reports, even though I am sending a value of 500.00 in the revenue parameter.
Here is the request I am sending to the measurement protocol:
https://www.google-analytics.com/collect?
v=1
&tid=UA-XXXXXXXXXX
&cid=XXXXXXX.XXXXXX
&uid=123
&t=pageview
&dh=http://example.com
&dp=order/thank_you
&dt=thank+you
&ti=127210
&ta=offline+conversion
&tr=500.00
&pa=purchase
&pr1id=1864
&pr1nm=Abc+Program
&pr1ca=Software
&pr1pr=500.00
&cu=CNY
&sc=end
&aip=1
The next day, when I check GA's Conversions reports, the goal conversion is tracked successfully, but the e-commerce report always displays the revenue earned for this purchase as 0.00, even though I've specified the price to be 500.00 in the request. I've already tried the following tasks to resolve the problem, but to no avail:
Double-check that Enhanced E-commerce is enabled in GA (it is).
Change &t=pageview to &t=transaction, but this modification results in neither the goal nor the revenue to be captured in GA.
Re-constructed the request in Google's Hit Builder and validated the hit (it is valid)
Sent the request to /debug/collect to validate the hit (it is valid). Below is the response:
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ {
"messageType": "INFO",
"description": "IP Address from this hit was anonymized to 106.111.63.0.",
"messageCode": "VALUE_MODIFIED"
} ],
"hit": "/debug/collect?v=1\u0026tid=UA-XXXXXXXX-X\u0026cid=XXXXXXXXX.XXXXXXXXXX\u0026uid=123\u0026t=pageview\u0026dh=http%253A%252F%252Fmydomain.com\u0026ti=127210\u0026ta=offline%20conversion\u0026tr=500.00\u0026pa=purchase\u0026pr1id=1864\u0026pr1nm=Abc%20Program\u0026pr1ca=Software\u0026pr1pr=500.00\u0026cu=CNY\u0026sc=end\u0026aip=1"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
Here is the screenshot of the above purchase in GA's conversion reports:
As shown above, the revenue from the purchase is 0.00, even though the revenue I sent to GA is 500.00.
Any idea why Google is not tracking the revenue?
Would also appreciate any thoughts on how to better troubleshoot this issue... because Google's /debug/collect script is not providing much insight into the problem. Any idea what other approaches to take for troubleshooting this?
Thanks!
Okay, found the problem. I didn't include the quantity of product purchased in the request data. In order for revenue to be tracked, you not only have to provide the product price (pr1pr), you also have to provide the product quantity (pr1qt).
So, I added the following parameter into the Measurement Protocol request:
&pr1qt=1
And now revenue is being tracked successfully.

Google Measurement Protocol not registering custom dimensions

I'm using the Google Analytics Measurement Protocol to register events with HTTP requests. I'm building this for a Roku app I'm working on. The events are getting sent and registered, but it seems the custom dimensions aren't working.
Here's what I'm sending
Destination URL:
https://ssl.google-analytics.com/collect
POST body:
v=1 // version
&dh=www.my-site.com // document hostname
&tid=UA-XXXXXXXX-X // Tracking ID / Property ID
&uid=(a user id) // user id
&cid=(an assigned UUID) // Anonymous Client ID
&sr=1280x720 // screen resolution of the tv
&t=event // Event hit type
&ec=ExampleCategory // Event Category. Required
&ea=ExampleAction // Event Action. Required
&el=ExampleLabel // Event label
&cd1=WAAA // Custom dimension 1, Station
&cd2=(some id) // Custom dimension 2, User ID
&z=1432199801 // Cache buster
When I go to Behavior > Events > Top Events in Google Analytics and set the secondary dimension as being Station for instance, none of the events show up. The events show up when I take off the secondary dimension though, so it seems like Google Analytics just isn't liking something about the custom definitions.
I've tried waiting 24 hours to see if there's a time delay problem, but that didn't help.
I've also made sure to turn on the custom definitions and set them to "Hit" scope type from the Admin panel in Analytics as well.
When I submit the above to https://ssl.google-analytics.com/debug/collect (the validation server that returns errors if there's something wrong with the request), it says the request is valid.
Any idea what could be going on here?
Thanks for the help!

Google Analytics won't track events

I'm using the Measurement Protocol for event tracking.
It correctly displays pageview hits, however fails to detect event hits.
Pageview that succeeds:
http://www.google-analytics.com/collect?
v=1
&tid=UA-XXXXXXXX-1
&cid=555
&uip=10.10.10.10
&t=pageview
&dl=mysite.com
Event that fails:
http://www.google-analytics.com/collect?
v=1
&tid=UA-XXXXXXXX-1
&cid=555
&uip=10.10.10.10
&t=event
&ec=category
&ea=view
All of the required parameters are included - v, tid, cid, t, ec, ea. How can I make the event work?
Looks like I'm missing something obvious. Thanks!
I think you are missing EL
ec – Event Category
ea – Event Action
el – Event Label
ev – Event Value
&t=event&ec=list&ea=accounts&el=userclicked&ev=10
When it works it should show up in the Real-time makes testing easer :)
Update:
I just tested with the following and it works:
http://www.google-analytics.com/collect?v=1&tid=UA-XXXXX-1&cid=555&uip=10.10.10.10&t=event&t=event&ec=list&ea=accounts&el=userclicked&ev=10
Note: Remember it takes between 24 - 72 hours for a new Google Analytics account to log data I don't think this is the issue since you said that pageviews are working. It also takes 24 hours for data to show up in the standard reports so you will have to check the real-time reports to see that its working.

Universal Google Analytics virtual pageview location

Situation
On our site we implement virtual pageviews for ajax filters and page scrollings.
When user open Rent page on our site:
real url: "/rent"
send to GA:
ga("send", "pageview", {page: "/rent/"})
When user scroll to second page:
we change real url via js: "/rent/?page=2"
send to GA (we care only about main page):
ga("send", "pageview", {page: "/rent/"})
Or when user drills down:
we change real url via js: "/rent/appartment/?page=2"
send to GA (we care about path):
ga("send", "pageview", {page: "/rent/appartment"})
But we noticed that really GA code does not take current real url (window.location) each time we call ga, but uses first time location. So when user drill down GA code send:
GET collect?...&t=pageview&dl=http://example.com/rent&dp=/rent/appartment&...
....
Referrer: http://example.com/rent/appartment
Here dl parameter is location of our page (not really current location) and dp is a page parameter in ga call. Notice that referrer is ok.
We decided to provide ga with real location (like in referrer) and change code to:
ga("send", "pageview", {page: "/rent/appartment", location: "http://example.com/rent/appartment"})
Problem
From now on I was satisfied, but was not guys that uses GA to analyze Paid Search effectiveness: bounce rate raised drammaticaly (something like 20% to 70%).
Drilling to the problem I've noticed that GA "loses" user when we remove campaign parameters (utm...) and send location without them.
Questions
Should I care about real location in this situation? How does location affects pageviews? How can I workaround or solve this problem?
Additional information
Seems like the main problem is that we drop CPC parameters when we change location for GA:
landing page: /rent?utm_source=...&... (or gclid for Google)
scroll down to second page: /rent?page=2 - there are no CPC parameters.
Additional information here: https://support.google.com/analytics/answer/1714454?hl=en
But I'm still can't figure out an appropriate solution.
When you send a hit to GA with analytics.js, it's going to send the data it has stored on the tracker object that you created when you invoked ga('create', ...);. You can override those values by passing in an object (as you did), but if no overrides are specified, that tracker data is used.
When the tracker object is created it collects data about the current page (e.g. url, title, window size, etc) and stores that information. It does not recollect that info before you send hits. You have to update it if that data changes.
That means if you're updating the page information in an AJAX site and want analytics.js to "remember" that you've updated the page, you'll have to set it on the tracker. The advantage to setting it on the tracker is that if you send other hit types (e.g. events, social, exceptions), you won't have to specify those new values each time.
So, instead of doing:
ga("send", "pageview", {page: "/rent/appartment"})
Do this:
ga("set", {page: "/rent/appartment"});
ga("send", "pageview");
Now, if you send an event later, the event will be associated with the apartment page.
UPDATE: there is now an official guide for how to properly track single page applications with Google Analytics.

Resources