Google Measurment Protocol - google-analytics

The question is, next, gmp has the ability to pass payload, where the mandatory field is clientId. However, there is an additional UserId field. Sending requests for the Google Measurment Protocol is carried out from the server, and it is not possible to get the clientId to send a request for a number of factors. However, on the client side, it is possible to bind the clientId to the UserId (in the google tag manager). Hence the question is why do I need to pass the clientId to the mandatory field, if I can pass userId and the analyst in theory should match this userId with the client. Actually, how to be in this case, ie whether the google analytics really associate userId <-> clientId and what to transfer instead of clientId in queries.

ClientID field is mandatory but you should consider two options:
Storing the cliendID since this value is available client side on the _ga cookie.
If that is not possible you will need to generate a random clientID and use it along with the UserID.
The first one is the ideal one since non of you metrics will be affected but sometimes it is just not possible to do it. The second one will match the the clientIDs under a single UserID but only under userID views.
The key in this field is to use NI (non interaction) on your hits send by measurement protocol.
Example:
I made a pageview manually (Measurement protocol bit with interaction) with a UID X and later i send a transaction with another ClientID but the same UID.
Normal view:
UserID view:
hope it helps!

Related

Why are users not being reported while events are reported in GA4

In my situation, some conversion events happen offline. For example, user visits a website, then books a meeting via calendly (I generate a user_id based on the email provided and save to CRM), then at some later point (maybe a few weeks later), signs a contract (i.e. makes a purchase).
I'm currently testing sending the purchase event via Measurement protocol, and because I don't have the original client_id, I figured I could just use the user_id as the client_id.
The problem is that GA4 shows the event and the value amount, but not the user - i.e. 1 purchase event, but 0 users.
Here's the payload for the Measurement Protocol that I'm sending:
{
client_id: userId,
user_id: userId,
events: [
{
name: "purchase",
params: {
value: amount,
currency: "CAD",
transactionId: transactionId
}
}
]
}
(userId, transactionId and amount are just variables in my code that supply the values)
The client_id seems to be meant to identify a device that the user is using. For offline events where user_id is used, I figured the "device" could be whatever, so I reused the used_id as the client_id.
Capturing the original cliend_id is non-trivial, and seems semantically wrong too (what if the user accessed the site through multiple devices - which client_id is the one I should be using to send an offline event?)
Question - why are users not being reported or shown in GA4?
For reference, here's what I found about the need to send a client_id that's already been used:
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.
(from https://developers.google.com/analytics/devguides/collection/protocol/ga4/verify-implementation?client_type=gtag)
On the other hand, it says here:
The second option for sending CRM data to Google Analytics is to use the measurement protocol. With this option, you can use the Google Analytics generated client Id or your own user Id as the lookup key to join your data with Google Analytics data.
(from https://developers.google.com/analytics/solutions/crm-integration#sending-crm-data-via-the-measurement-protocol)

Can WebAuthN be used to identify an individual?

I'm wondering whether WebAuthN APIs can be used to identify an individual. Do any of the following hold
Can the authenticator ever return info about the individual e.g. First name, email etc
Will the authenticator always give us the same ID back for Alice when she uses this device regardless of which website I'm requesting from?
Will different devices ever give back the same ID for the same user?
Can the authenticator ever return info about the individual e.g. First name, email etc
It can if you set personally-identifying information to the value of user.id in the options you pass to navigator.credentials.create(). Also referred to as the "user handle", the spec includes a section specifically about how this value is one way the API can leak personally-identifying information if you're not careful what value you set user.id to.
Will the authenticator always give us the same ID back for Alice when she uses this device regardless of which website I'm requesting from?
The authenticator will not give back the same ID on every website. Every successful invocation of navigator.credentials.create() generates a unique credential bound to the website, meaning every website would have to use the same value for Alice's internal user ID for this to even have a chance of happening. And for any given website the authenticator only gives back the value of user.id (as passed into navigator.credentials.create()) as userHandle in the response from navigator.credentials.get() when Alice logs into that site.
Will different devices ever give back the same ID for the same user?
Different registered authenticators would give back the same ID for Alice provided you specify the same value for user.id whenever Alice registers an authenticator.

How does google set the fullVisitorId/Client ID in Bigquery/Google-Analytics?

I have been trying to understand the concept behind google client id, set as fullvisitor id in BigQuery Export Schema
I know that to define a session, a unique combination of fullvisitorid and visitid has to be found.
However,I couldn't find a good explanation regarding how google defines this id, and how permanent it is across sessions.
Thank you very much!
I'm not sure about what you didn't understand, but the client id is generated on the user's browser when the GA script is initialised and stored in the cookie.
After that, every hit sent by that instance of the script [that has the cookie] will have the cid value as the client id.
When implementing GA you can also set that value yourself if you want. Although there are better ways for doing that.
Here's some documentation on the cid and here is how the session is defined (thus how the session id is derived during data collection)

Custom metric to track email opens

I am trying to track the number of email opens of a mailing.
This mailing is not personalised, so each receiver will get exactly the same email contents.
So far I have found out that I can add a tracking pixel in the mailing, which will send data to GA that a user opened the mail (images were loaded).
Example code:
<img src=”http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-X
&cid=EmailOpenTest&t=event&ec=email&ea=open&el=EmailOpenTest
&cs=newsletter&cm=email&cn=Email&cm1=1″ />
'tid' will be our custom tracking ID.
This all works, as when this link is opened the total number of hits increases.
But my question relates to parameter 'cid'. For testing purposes, I have set this here to "EmailOpenTest". But this should be a random/unique ID per user actually. But as the mailing is not personalised, I wonder if it would be possible to track individual users?
Does this mean I have to include javascript in the mail? Would that even work in all email clients? Or are there other options?
All suggestions are welcome.
Assumption: you are using a mail client like Mail Chimp
Assign a unique id to every email on the email list. lets say this unique id is uid
Create a custom dimension in GA, lets name it as Client Mail Id with index say 1
Create the same pixel just like you have created above in the OP.
Add a custom Dimension in the hit as
http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-X
&cid=EmailOpenTest&t=event&ec=email&ea=open&el=EmailOpenTest
&cs=newsletter&cm=email&cn=Email&cm1=1&cd1=uid
In place of uid, you actually need to pass the mail list unique id for that email
How it will work
Once the user sends this hit, your unique id will be recorded in custom dimension 1.
Generate a custom report in GA with event category=email & event action=open and add a dimension custom dimension 1.
All the id's displayed there have actually opened the email ;)
PS: It's tried and tested, so won't cause any issue. Also if you don't want to use custom dimensions, you can also send this id in event label or event value
PPS: In any mail client, getting unique value for that email is pretty easy. You can actiually use its position number or add another column for the unique id, then grab that id win the template
The cid is the clientId, an identifier that is used to aggregate pageviews into sessions, and sessions into unique users.
The way to use that in email-tracking would be to capture the client id when a user subscribes to your newsletter and then insert it into the email links. Since your mails are not personalized this will not work.
If you use a random ID you will not be able to link the request from the mail to an existing user. So one way to deal with the problem would be to ignore it - using a constant userId would still give you an event count (the unique events metric might be a little of if users click the link multiple times within a session lifetime).
If for some reason you absolutely need to track these as different users you can set up a redirect - do not send data to ga directly from your mail, instead call a script on your server that inserts a random clientId and then sends the data to Google.

How to send Measurement Protocol if there is no ClientID?

I need to send Measurement Protocol, but clietID cookie may not exist. ClientID is required parameter. What to do in this case? Generate it? In which way?
(I need to do in on PHP)
The clientId is used to tie up the session. You can post a dummy clientId as a UUID, but the event will be stored in a new session. Take a look at Client Id section within Measurement Protocol - more information on UUID can be found inside of A Universally Unique IDentifier (UUID) URN Namespace
If you are working with a User (as opposed to standard) View, the UserId can be used to tie multiple sessions together, providing the UserId (UID) matches
If anyone else have the problem that hits wont get registered, if cid is empty, I just found out that the docs are wrong:
Client ID: Optional. This field is required if User ID (uid) is not specified in the request.
cid is always required, even if uid is set. Otherwise the hit won't get registered.

Resources