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
Related
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.
Some GTM wisdom needed.
We use measure protocol to send some transactions to Google Analytics & using GTM too in "thank you page". We are not happy with that.
Is there a way we can send Data Layer Variables from backend using some GTM call? I want to know how you solve that using GTM & dataLayer
My first idea is to try emulate measure protocol using something similar to https://developers.google.com/tag-manager/devguide#adding-data-layer-variables-for-devices-without-javascript-support
Context: Some payment methods notify transactions to my backend system via a background HTTP post method call from their backend system, not an interactive browser (where server-side code do the measure protocol request)
I would like to add more clearance into terminology you are using.
Measurement protocol is HTTP request to google-analytics.com containing all key=value pairs in its query string or in POST data.
Use documentation on Goodle Developers. This is direct input into Google Analytics.
DataLayer is usualy JavaScript object containing key : value pairs Check documentation here. This keys are then accessible in GTM interface to be paired with pre-prepared TAGs in their particular fields. In case of non-javascript solution are these parameters translated into Image Request and sended in different way to Google Analytics.
Adding variables for devices without JavaScript is about specifying JS dataLayer object in flatten mode like GET parameters. This mean you do not emulate Measurement protocol, you "simulate" dataLayer.
My suggestion:
If you have your GTM setted in standard manners (by Google Documentation), then use "Adding Data Layer Variables for Devices without JavaScript Support" and it will save you a lot of time.
If you are using custom JavaScript implementations, do it with Measurement Protocol by Image Request.
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...
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.
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.