Sending multiple item transaction for classic ecommerce via measurement protocol - google-analytics

I am trying to send a single transaction via measurement protocol for non enhanced ecommerce. For some reason I am not able to understand how I am to send a transaction with multiple items.
Sifting through the Google Analytics measurement protocol documentation yielded no helpful information and I would like to know if someone has any experience in doing this.. For now I assume I would have to send a different request for each item, am I wrong?

To send multiple hits in a single request, use the /batch endpoint instead of /collect and specify each payload on its own line.
For example, to send pageview hits for the "Home", "About Us", and "Contact" pages of a website, you could send the following batch request.
POST /batch HTTP/1.1
Host: www.google-analytics.com
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fhome
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fabout
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fcontact
directly from the documentation Batching multiple hits in a single request

Related

Importing CRM data with Measurement Protocol: Is it possible to batch send for multiple UserIds?

I'm trying to send data from my CRM to GA via measurement protocol, however I don't understand how to send all my custom dimensions for ALL uids at the same time. Would I have to make hundreds of POST requests?
Also, we are not currently tracking the users of this website on GA, so there is no user ids to make a match, we merely want to have this data available for remarketing in Google Ads.
In this case, would Data Import be the best since we can upload our own IDs via a custom dimension?
Ex
POST /batch HTTP/1.1
Host: www.google-analytics.com
v=1&tid=UA-XXXXX-Y&cid=554&t=pageview&dp=%2Fhome
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fhome
v=1&tid=UA-XXXXX-Y&cid=556&t=pageview&dp=%2Fhome
The batching method allows for a max of 20 requests per batch. Each request in the batch is a single hit. Doing something like the following would record Custom dimension 1 for userid 1 2 and 3.
POST /batch HTTP/1.1
Host: www.google-analytics.com
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fhome&uid=1&cd1=Customdimension1
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fabout&uid=2&cd1=Customdimension1
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fcontact&uid=3&cd1=Customdimension1
By using uid it helps Google analytics preform internal processing by the user. If you put the user id as a custom dimension this will not happen as Google analytics doesn't understand that this will be your user id.
User Id
This field is required if Client ID (cid) is not specified in the request. This is intended to be a known identifier for a user provided by the site owner/tracking library user. It must not itself be PII (personally identifiable information). The value should never be persisted in GA cookies or other Analytics provided storage.

HTTP Batch Request Google Analytics Not Working

As per Google Documentation for batch request for Google Analytics, has been used for sending multiple hits as a single request.
I have tried the URL using an resteasy client but it not works
only a single hit has been registerd in google analytics server.
My question is how to form HTTP Batch request for Google analytics Batch Hit?.
POST /batch HTTP/1.1
Host: www.google-analytics.com
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fhome
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fabout
v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fcontact
I have tried normal Batch Request for google also, still no luck
Little correction, actually batch was working, you can check in the Realtime->Screens->Last 30 mins. There you can find the list of Activities send. :-)

Which technology is used in Google Analytics?

I am wondering which technology is used by Google in Google Analytics.
When i checked my website's in Google Analytics real time overview, i find out that there is no http request in network monitor.
Can any one tell me which technology is this..
Thanks in Advance..
Every part of the Google Analytics collection is based upon HTTP requests with the Measurement Protocol.
POST /collect HTTP/1.1
Host: www.google-analytics.com
payload_data
You are likely using Analytics.js which collects information from the user agent and sends hits to www.google-analytics.com

Measurement protocol Usage

I am completely new to the Google Analytics Measurement protocol.
Trying to fetch the results and load it in iframe of an registered tid domain.
My query string looks something like this:
http://www.google-analytics.com/collect?v=1&tid=UA-XXX-1&cid=555&t=pageview&dp=%2Fauth"
But i get the response as : GIF89aÿÿÿÿ,D;
What am I doing anything wrong? I also tried passing domain name with it and its title. Still no success.
And also do I need to call this get or post from the origin domain or can I do it from Postman-Rest client?
I think your having an issue with understanding what the Measurement Protocol is.
You said:
Trying to fetch the results and load it in iframe of an registered tid
domain.
What the measurement protocol is for:
Measurement Protocol Overview
The Google Analytics Measurement Protocol allows developers to make
HTTP requests to send raw user interaction data directly to Google
Analytics servers.
The measurement protocol is for sending hits to Google Analytics, If you want to get your Google Analytics data out you use the Reporting API
Response
The response you are getting back from the measurement protocol is good it means it recorded your message. GIF89aÿÿÿÿ,D;
What you're seeing is the content of the 1x1 GIF pixel that Google Analytics uses, which you can safely ignore. As long as the response code of your request is 200, you should be fine.
The origin domain of the request doesn't matter; you can—for instance—also send Measurement protocol requests from server-side scripts and it still works.

Measurement Protocol HTTP Batch event POST instead of POST per event?

I want to batch my requests to the Google Analytics Measurement Protocol
POST /collect HTTP/1.1
Host: www.google-analytics.com
payload_data
I'm developing in Unity 3D, but mainly I was curious if anyone had ideas so I can reduce the number of http requests from the client.
NOTE: I have no plans to use Googles Analytics SDK for Unity. Please do not suggest. I want to use the Measurement Protocol API.
Thanks,
NOTE: multipart/mixed might be a good solution, but I suspect the API needs to support it. Not sure if that is the case (at least not documented).
Seems like this should be a common problem though.
Google Analytics Measurement Protocol Batch Requests
You can batch multiple requests into a single post request.

Resources