How is Google Analytics Measurement Protocol different? - google-analytics

I was checking GA Measurement Protocol to send data to GA from backend.Which is working fine.Url i am using is:
https://www.google-analytics.com/collect?tid=UA-XXXXXXX-1&v=1&cid=9350&dp=home&t=pageview
(Please replace UA-XXXXXXX-1 with your own tracking id.)
Now i have a website which is GA enabled using javascript way.I checked in Chrome inspect that it sends information to google through url:
https://stats.g.doubleclick.net/__utm.gif?utmwv=5.6.5dc&utms=4&utmn=1588741400&............
I can use this url too to send information to google from backend. What's special and new in Measurement Protocol because using this url too i can send data to google for analytics purposes?
I need to send data from backend to GA so please guide.

The measurement protocol is now the "backbone" for data collection for Universal Analytics for all versions (web, mobile etc). Unlike the gif-method it is well documented and it can be called from every device/programming language that can send http requests (it will still return a transparent gif, though).
The main reason for using the measurement protocol is that everything else is deprecated and Google has announced that support for older tracking methods will be dropped. It looks like your second example uses an older version of the Analytics tracking code, current versions send their calls to the https://www.google-analytics.com/collect endpoint. You should not invest a lot of effort in developing solutions based on deprecated technology, especially if it offers no advantages over the current versions.

Google measurement protocol is very useful when implementing distributed solution of a service like restful APIs.
The client is not known by the server, each client world wide can call the rest API so no javascript code is possible to be injected at the client.
Measurement protocol enabled us to track which kind of devices are calling our API, how many requests per endpoint, etc...

Related

How to send basic geo data in the measurement protocol api?

I'm sending ecommerce data using the google analytics 4 measurement protocol and I also load the basic ga4 js snippet to track geo and other flow data.
The only issue is, as expected, I don't get any geo location data when the user is ad blocking and the ga4 js doesn't load.
Is there a way to send basic geo location data using the measurement protocol api so the realtime map works even when js is being blocked?
You need to develop your own server-side service using the GA4 Measurement protocol, and make a fetch() yourself in javascript to that web-service:
https://developers.google.com/analytics/devguides/collection/protocol/ga4
But some user_properties parameters, like geolocation, are not documented (or do not exist) yet.
See question here: How indentity user country through GA4 measurement protocol

How can I use Google Analytics without its gtag.js library

I am having some pages where I need to track page views and get data for reports. So I need to use some tracking events without using gtag.js.
I have tried solutions like GIF Request Parameters
But this solution was there in ga.js and its a legacy
The format used in your linked documentation is deprecated since Google introduced Universal Analytics in 2012.
However the current solution to send requests to Googke Analytics without a library, the Measurement Protocol, works broadly the same way. You have an endpoint (google-analytics.com/collect) and add the necessary parameters as described in the reference, depending on what kind of interaction you want to track. The endpoint returns a 200 http status and a gif (no matter if the request has actually been logged in analytics, this just confirms that you actually hit the server).

Audience report using the Measurement protocol

We have been testing the measurement protocol for a while now to pass Google Analytics information from our servers. We are passing our internal unique user id to tid/cid parameters and not the ga's.
Right now it looks like that in our current setup we are not able to generate any Audience reports and I would like to verify my concern that this is due the fact we are passing our own unique userId to the cid parameter.
Is it possible to generate Audience reports using the measurement protocol without ga's cid?
The way Google Analytics handles Audiences is tying the CID (or UID) with a third party cookie in the doubleclick domain, that is sent using a non-documented parameter of the measurement protocol.
This is only enabled once you turn on advertiser features in the Google Analytics interface. Because you can't access the doubleclick cookies from your server you won't be able to include that in your request.
In other words if your implementation relies solely on the measurement protocol from your server side it won't be possible to have audiences populated. If your implementation includes a mix of web tracking (using the supported client libraries such as gtag.js) and offline using measurement protocol it might be possible to make it work if you are able to use the same Ids on the offline and online tracking methods.

Google Analytics for TCL-TK

Is there any code for using Google Analytics on a TCL-Tk program?
I've tried to implement it "handmade" using a webserver, and sending messages via TclWs but I'm sure that Google Analytics can be a better (or best) solution for this problem.
You might want to have a look at the Measurement Protocol API:
The Google Analytics Measurement Protocol allows developers to make
HTTP requests to send raw user interaction data directly to Google
Analytics servers. This allows developers to measure how users
interact with their business from almost any environment. Developers
can then use the Measurement Protocol to:
Measure user activity in new environments.
Tie online to offline
behavior.
Send data from both the web and server.
Note: The
Measurement Protocol only allows developers to collect
user-interaction (event / hit) data. It does not allow developers to
upload aggregated data like tables.

Using Google Analytics for an API

I have a small API written in node.js that has no website attached, it works only on AJAX calls. I want to know if it is possible to use Google Analytics, or other good Analytics tool to monitor traffic.
I think it depends on how you have things set up but I wonder if you couldn't just add the normal JavaScript tracking to your API since its JavaScript as well. In the event you cant do that you should check out the Measurement Protocol Overview, it will allow you to send the raw data to Google Analytics yourself.

Resources