Measurement Protocol with uid but without cid not received in GA - google-analytics

I have a booking system where a booking can be made:
1. immediately by a customer, or
2. on their behalf by a customer service agent.
For 1, I've had success POSTing an event hit to the Measurement Protocol with a cid and our uid for a "purchase". Initially without the cid, it wasn't working despite the docs saying only one of uid or cid are required.
For 2, which isn't customer initiated, when I don't pass a cid nothing comes through to GA (neither the real-time dashboard or the ecomm report).
Here's the hit for option 1, broken in to lines for easier viewing:
t=event
&v=1
&tid=UA-XXXXXXX-2
&ec=Ecommerce
&ea=Purchase
&ti=176410
&ta=Some+Affiliation
&pa=purchase
&tr=123.45
&pr1id=Repair367
&pr1nm=Something+Replacement
&pr1pr=123.45
&pr1qt=1
&pr1ca=Repair%2FInspection
&pr1ps=1
&cd3=None
&ni=1
&uid=469585

OK, so it turns out this is the case:
If using cid, your hit will appear in your property's standard view's real-time Event screen (immediately) and ecomm Sales Performance screen (~10mins later for me)
If using uid and no cid, your hit will appear ONLY in those screens under your property's UserID view.
I'd been looking in the standard view and nothing was appearing as soon as I swapped over to a uid-only hit when it was customer service initiated. So although the docs say only one of either uid or cid are required, it should mention it has a significant affect on where the data is viewable in GA.
Sigh.

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)

User's google calendar ID changes when primary email is updated

Essentially I've noticed that when a user's primary email is updated on their google account, their calendar ID will also change (e.g. ID will change from john#company.com to john_new#company.com).
This is a problem because I work on an application that relies on the calendar ID being a stable identifier for users. For example, lets say user A at a company schedules an event to their calendar through my application. We'll save metadata related to that event in our own database along with user A's calendar ID to denote that the event was scheduled to that calendar. This is important because we use this information to ensure that only users with write access to this calendar ID can edit this event from our application (important for security purposes).
Lets say user A gets their primary email updated, which causes their calendar ID to also change. Now, when I query the CalendarList endpoint to get a list of user A's calendars, I get back the new calendar ID, which makes my application think that user A should not have access to edit the event they just scheduled since that event was scheduled to a calendar ID that user A no longer has access to.
Is there a way around a problem like this? I can't find an endpoint that will return user A's "archived" calendar ID in addition to their new one. More deeply, I don't understand why their calendar ID changes as it feels like IDs should be stable identifiers...
In this case, by testing and working with the calendar API and Google Workspace it's a fact that the Calendar ID will always be the email address of the user account it’s associated with. I wish there was actual documentation but this is only from testing that I have verified this. There are other threads that explain the same, in this case with your situation you should modify your app in a way that the CalendarID is not based in a stable ID, as this depends on your email address.

Firestore Analytics - Is there a limit to the number of parameter's values in one event?

So let's say for example, I have user_id#1234 in chat room_id#4321 and I'm keeping track of:
The total number of messages for this particular room_id#4321, and
The total number of messages user_id#1234 sends in this room - (It's important to associate the user's messages with the room because I need to track the total user's message count PER each chat room.)
Here's the approach I got so far in my attempt to keep it to one event: On Firestore Analytics, I've created a custom dimension with the event "room_messages" and I'm able to log the events like so every time a message is sent:
firebase
.analytics()
.logEvent("room_messages", {
room_id: room_id,
user_room: `${user_id}-${room_id}`,
});
But particularly for the user_room parameter, since there could be so many users and rooms, is there a limit on the number of parameter values? ie there could be a ton of the event (room_messages) -> parameter (user_room) -> value (user_id-room_id)
And on top of that, how do you even view these events and their parameters for insights? Whether on Firestore or Google Analytics, it seems like I can view all the total events that have occurred just fine, but for viewing the events AND their parameters, I am only able to view that from what events were triggered in the last 30 minutes.
Appreciate any help!
Update: The parameter has to also be defined using Custom Definitions. Now the room_id tracking information shows up on the room_messages event page.

Measurement Protocol Only Tracks When I Provide cid (Doesn't' Track When I Only Provide uid)

Measurement protocol tracks when i send a hit with cid, but when i remove cid and use uid instead nothing is recorded.
I've waited for 48 hours.
I've looked in my userId enabled view.
I've enabled session unification
v=1
&t=transaction
&tid=UA-XXXXX-1
&ti=123456
&tr=9.99
&uid=123-456-789y180
&cid=
Not sure if this is obvious, but the uid tracking only works if it has been assigned a cid previously through the front end. Using dummy data for testing won't work.

reporting on event hits in google analytics

I have been tasked with using Google Analytics to report of use of a desktop app so we can see which parts of the program are being used and how heavily, and potentially also see which companies are using which parts of the program (each company has a unique companyID). Ideally I'd like to be able to look at correlations (e.g., How many users who use report A also use process B?)
I currently have my program set to fire off a call to analytics. I've set it up to use the event tracking, but I'm open to app/screen tracking or something else if something would work better. I'm passing values like
v=1
&t=event // Event hit type
&tid=UA-XXXXX-Y // our ID; real code has valid value here
&cid=12345 // CustomerID
&ec=JobFinancialReport // Event Category
&ea=Run // Event Action
&el=Manager // Event label
&ev=7 // Event value
What I can't figure out is how in Google Analytics to set up reports that would show me something like:
CustomerID Category Label Total Hits Unique Users
12345 JobFinancialReport Manager 27 2
12345 MarketingReport1 Manager 6 4
I'm totally new to analytics so pardon my ignorance if I have some key misconception here. I've searched Googles sites and other questions here, but I may be wording my question incorrectly so I'm not finding something that's there. This is only one example; in some cases we might want to see how broadly each customer is using the program; in other cases we'd want to take the customerID out and just see how much a particular report is being used overall. Appreciate any guidance. Thanks.
The "cid" parameter is the client id, the value that is used to stitch single interactions into sessions and users.
The first problem that comes to mind with your setup is that the client id is not exposed in the user interface (with the single exception of the user explorer report) or the API.
You would need to implement this via a custom dimension (probably user scope, since it probably will never change for a given user) where you pass in the client id (you still need the cid parameter).
Then you could create a custom report (or create a report in Google Data Studio) with the custom value as primary dimension and your selected metric.
If you want to report "Unique Users" you would probably need to create a cid per logged-in user (if all users of the app have the same cid then you will always have but a single user reported). You should then probably create a second custom dimension for the company id, so you can segment your reports by company.
you can use custom reports in google analytics to get your desired output. here is how to create custom reports https://support.google.com/analytics/answer/1151300?hl=en

Resources