Don't panic, we can also collect and send data to Google Analytics from these devices, as long as they are connected to the Internet.
As we saw in previous articles, both a website and a mobile application can send data automatically to Analytics, well in the case of applications, in packets every so often. But if what we want is to send data from other devices, we will have to do it by hand, using the measurement protocol implemented by Analytics in its Universal version, which defines how to generate these results to be sent later to the Analytics servers.
Overview of the Measurement Protocol. A brief introduction to what the Measurement Protocolis,
Adeveloper's guide to the measurement protocol. A description of how to send data to Google Analytics using the Measurement Protocol (which is really how both analytics.js and the SDks send data.
Parameter reference of the measurement protocol. List of the parameters and values that we can use to build the hit that we will send to Google Analytics.
Measurement protocol policy / SDK / UserID. A very brief document that informs us of the privacy policies that we must comply with when sending data to Google Analytics servers.
Okay, and now you may be wondering, what use can this have in practice and how is it done? Well, uses, unlimited, from measuring the traffic of people through a physical store using WiFi receivers or beacon receivers and thus make us a map of routes, to, for example, to know how many drinks a day are bought in a machine that we have in a train station, and what kind. All this from Analytics.
OK, we can know the latter by looking at the counters of the machine, but what if we want to analyze it together with the sales on the Web or we want to know what the weather was like at each location of each machine to try to establish a relationship between weather vs. sales of a particular product?
How to implement the Google Analytics measurement protocol
And how it would be done, in our hands, well in the hands of a programmer, fall the two steps.
First collect the data we want from the device, identification of the device, location, time of sale, how the payment was made, price of the sale, product sold... whatever we want to measure.
Secondly, and also through programming, generate an http POST or https POST request to the Google Analytics servers to send the data we have collected, which is called a load or a hit. We will do this by building, from scratch, a URL, where each parameter has a key and a value separated by a character "= " and each parameter is delimited with a character "&", with a format similar to the one you see below.
It's the same thing that appeared in the article where we talked about how GA collects and sends the data to the server.
If you still haven't understood it, don't worry, it took me a while to finish polishing some doubts and I had to go to a programmer friend, thanks Jesus for your patience XD.
I'm going to try to explain it with the example that occurred to us when we were leaving the Mexican place where we had lunch so that he could explain it to me.
In the Mexicano there were dishes and drinks, which you could choose to make a menu, there were also people behind the counter who attended to your order, they ordered it to the kitchen, chopped what you were going to eat and drink at a POS, took the ticket and charged you. Let's imagine that we want to measure, with Google Analytics, what elements make up customer orders, who serves them and what we bill.
What would have to be done is to program the POS, so that it captures the data that the "shopkeeper" enters: order, products that compose it, number of people, unit price of each product and total price of the order, for example. Once this data is captured, in the same way that the ticket that is printed for the client is generated, the program would be responsible for building the URL that you want to send to the GA server, which will have a fixed part and a variable part and that could look something like this:
The variables and data in red are mandatory and tell Analytics the protocol version, the property to send data to, the client id and the type of hit. This last parameter can take the following values: "pageview", "screenview", "event", "transaction", "item", "social", "exception" or "timing". There are more variables, but these are the mandatory ones, you can see all the variables defined by Google at https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters?hl=es.
The variables and data in green are the ones we have defined and created and correspond to the data we want to capture (products, unit prices and total price).
Once Analytics receives this string, it will process it and include the data in the corresponding tables, making it available for analysis.
In short, using the GA measurement protocol, you can obtain data from any device, both present and future, and integrate it into your Google Analytics account for further analysis, regardless of the language or operating system that supports that device.