We have a Lead generation website, where conversion action is a form submit. A percentage of these leads get enrolled offline.
We plan to use measurement protocol to tie-back this revenue to google analytics.
The set-up is as follows:
Enable User-ID feature in Google Analytics
Sending the Unique ID generated by our CRM software as the User-ID in google analytics.
When one of the lead converts offline, we pass that information back to GA - and the associated UID shows the final conversion as well.
How do we proceed with step 3 and tie-back the revenue to the User-ID from transactions that happened offline?
As per explanation given in measurement protocol, only CID can be used to send the transaction values to GA.
Is it possible to do it using UID only?
Thanks
It is possible to send a UserID via the measurement protocol please see the following page for details:
https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#uid
In essence you add &uid=USER_ID to your request URL
However you must also supply a ClientId, the usual approach would be to store the ClientID of the user against the user record in your database when they submit the form online, which you can then later use to reattach to the request you send via the measurement protocol.
To get the clientId from the form is simple
ga(function(tracker) {
var clientId = tracker.get('clientId');
});
https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#getting_the_client_id_from_the_cookie
Related
Is it possible to use GA4 Measurement Protocol to send events to Google Analytics and view and analyze them in the GA dashboard without using gtag.js or any other front-end script? The use case would be that some events are being sent to my server and I will just push these events to GA through the API.
One thing that makes me think is that the official Measurement Protocol API say:
In order for an event to be valid, it must have a client_id that has already been used to send an event from gtag.js. You will need to capture this ID client-side and include it in your call to the measurement protocol. In send an event to your property, we use "client_id" as the client_id. You will need to replace this with a real client_id that comes from gtag.js.
(https://developers.google.com/analytics/devguides/collection/protocol/ga4/verify-implementation?client_type=gtag)
That suggests that only events that have a valid client_id that originate from gtag.js will be counted.
I did some experimenting with randomly generated client_ids and what I discovered was that I was able to see my events in the Realtime section of the GA4 console (the Event count by Event name section), but all the other sections would be empty and the Users in last 30 min section would always show 0.
Can someone please explain to me why it's zero and if such a use case is valid at all? Thanks
tl;dr
You can use any value in client_id, as long as it uniquely identifies the user (we use a GUID/UUID), but it seems like you also need to send a value in user_id. We use the same value for both.
Also, you need to add the 'engagement_time_msec' parameter to get any user metrics to register.
Longer answer:
We're trying to do the same, i.e. send all events to the GA4 Measurement Protocol from the server, so that it is not dependent on the current user's GDPR cookie settings.
We currently do this for a Universal Analytics property with no issues, but it seems that Google is trying to prevent this in future, by restricting the scope of the Measurement Protocol in GA4, whilst forcing everyone to move to it by July 1st 2023. See the documentation at https://developers.google.com/analytics/devguides/collection/protocol/ga4#full_server-to-server, where it states:
While it is possible to send events to Google Analytics solely with
measurement protocol, only partial reporting may be available. The
purpose of measurement protocol is to augment existing events
collected via gtag, GTM, or Firebase.
We have something working with GA4, in that the events are being registered on the GA4 property correctly, using a client id that is just a GUID/UUID that we define in our own site cookies. So, any value can be used in the client id, as long as it uniquely identifies the user. The same value is used to populate the user_id parameter.
When sending events, the realtime event details were showing on the GA4 dashboard, but user metrics were not until we also populated the 'engagement_time_msec' parameter, as described in https://stackoverflow.com/a/71482548/7205473
We still have issues with things like getting the user location and the platform details, which previously were automatically populated by passing the IP address and the User Agent, but which seem to no longer work in GA4.
We were also passing page load timing events through the Measurement Protocol, but again, these features seem to have been removed in GA4.
It is possible to use GA4 directly without gtag.ja or the Firebase SDK. Its not supported, so it takes some work. We have this working in a desktop app reasonably well. There a couple things that need to be done.
As stated elsewhere the "engagement_time_msec" param must be set using the "_et" parameter. This is the number of milliseconds between now and the previous event.
The client id "cid" has a specific format; it should be:
"randomNumbers(10).unixTimeStamp()"
The session id "sid" format is:
"randomNumbers(10)"
The "_z" parameter needs to be set. I think this is a cache buster. Looking deep into the gtag.js code it is a url safe base64 encoding of "CCD", which always results in the value "ccd.v9b"
The page hash parameter "_p" can be set to this; not totally sure its correct but it works.
"randomString(3).randomString(3)"
Set the "User-Agent" HTTP request header in whatever framework/lib you are using. GA4 uses this to determine many things including Operating System. You will need to create a fake user agent based on the local device information. This is what we use for a Windows 11 x64:
"myco.testapp/4.0.0 (Windows NT 10.0; Win64; x64)"
The IP will be taken fromn the web request which is where the geolocation data comes from.
Since a full working example is worth 1,000 words of documentation; here is a "test" event with a parameter "animal=dog":
https://www.google-analytics.com/g/collect?cid=0078745494.1659679529&_et=364&_p=pfJ.Aev&seg=1&sid=2678664821&tid=G-???&ul=en&v=2&_z=ccd.v9b&en=test&ep.animal=dog
It's possible to extract outgoing GA4 request from a GTM container debug/preview view and map any GA4 (automatically collected and custom) event.
Example page_view request URL:
https://www.google-analytics.com/g/collect?v=2&tid=G-XXXXXXXXXX>m=3oes1i1&_p=1545013558&_dbg=1&cid=P%2FdJWyULMwcT21TMrzn7pZdlNt%2FxtttGVqGUmqNYbhc%3D.1669722847&ul=nl-nl&sr=2560x1440&uaa=x86&uab=64&uafvl=Not_A%2520Brand%3B99.0.0.0%7CGoogle%2520Chrome%3B109.0.5414.75%7CChromium%3B109.0.5414.75&uamb=0&uam=&uap=Windows&uapv=10.0.0&uaw=0&_s=1&_uip=XXX.XXX.XXX.X&sid=1674235261&sct=1&dl=https%3A%2F%2FXXXXXXXXXX.com%2F%3Fgtm_debug%3D1674235654105&dr=https%3A%2F%2Ftagassistant.google.com%2F&dt=OM%20test&jscid=XXXXXXXXXX.1669722847&seg=1&en=page_view
Tip: use Postman to analyse and experiment with parameters
regardless of the platform used to make a call the Measurement Protocol, you should use a client id generated by gtag.js, or the app ID if using Firebase.
I have Google Analytics set up, and have been using it without sending in User Ids for over a year. I have thousands of users that we're tracking, and now we'd like to start tracking users by USER-ID.
If I begin sending in the user id using analytics.js, will Google Analytics count the user as a new user, even if the user is an actual return user to the app?
I want to avoid this if possible. I'm hoping GA is smart enough to simply replace the existing client id with the user id info, that way existing users aren't tracked as new ones.
Client ID will still be collected and sent to Google Analytics regardless of you sending User ID.
I have a question regarding User Deletion API for Google Analytics. We have a Property and View that does not collect UserID or ClientID as Custom Dimension, but we have a lot of PII data in our Events report (emails and phone numbers).
When i go to User Explorer i can get the ClientID, but unfortunately as far as i know this report is not available in any API versions of Google Analytics.
My question is HOW can i then delete all these PII without knowing the ClientID? I do not have a 360 account.
Unfortunately I think you've done your research correctly and I'm afraid there aren't more options available than what you already listed:
You have 2 ways of deleting data:
User Deletion API
Deleting views (I know it's too radical, but that's the only other option)
As for option 1, indeed, none of the reporting APIs expose the Client ID or the User ID, so you have 2 options:
Export the Client ID manually from the User Explorer report, but you won't be able tell which PII is associated with which Client ID
Implement a custom dimension to store the Client ID so you can then identify the corresponding PII, and automate that process if you want to
We're looking to set up measurement protocol requests to import non PII CRM data to Google Analytics. This will be tied to a client ID that is stored in the CRM and the measurement protocol request would be set to a non-interaction hit populating user scoped custom dimensions.
The CRM data is populated via two portals one for a global market and one for China, with each having their own property number.
The issue currently faced is it is unknown which portal the CRM data originated from and therefore which tracking ID to use with the measurement protocol request.
Even with the request being a non-interaction hit, if a request was made to both tracking IDs, what would happen with the data if the client ID didn't already exist?
Would a new user still be created?
Would it be disregarded?
Are there any ramifications of such actions?
Just to make sure my assumptions on this are correct I tested this (i.e. sending a single non-interaction event with a set clientid) with an empty view, and the answers are:
a new user is created
no
yes, there is at least one ramification since GA counted a user, but no session (I guess since technically there was no interaction). This looks rather odd in the reports. Also of course no pageview for that user.
I am sending an offline event to Google UA using their measurement protocol. I am trying to tie it to the users previous visits to get attribution and using Google's own Client ID from their cookie to do that. While the event does appear in Google UA, it is not tied to other client id sessions.
Here an example of the API call
In this example, "1859919454.1455744839" are the X.Y elements parsed from the _ga cookie's client id.
Am I doing something wrong or making some wrong assumptions about google analytics accepting their own Client ID instead of creating and using my own as suggested in their measurement protocol's parameter reference? I have seen plenty of forum threads that suggest google's own client id is acceptable.
I checked your API call and you are missing a measurement protocol parameter in the URL "t" (https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#t)
which defines what type of hit you are trying to send i.e. event or pageView
Google has created a debug tool to check whether the url generated is valid or not. You can also send hits to your GA using the tool.
https://ga-dev-tools.appspot.com/hit-builder/
turns out there is an unpublished parameter in the newer UA interface that allows for strict or loose userid. If strictly enforced, the userid MUST be a UUID. If strict is false it will accept google's own user id. Once that parameter is passed everything worked