Event parameters with Firebase Analytics & Data studio - firebase

I have an app where users can select multiple foods that are their favourite.
When the user has selected the foods (max ten) that are their favourite, I loop over this data and fire an event for each food
E.g
logEvent("fav_food", { value: "[food]" })
In datastudio, how would I create a chart that shows the most popular values sent in the "fav_food" event?
Alternatively, if any of you know how to handle string[] values in firebase Analytics differently maybe via a user property, that would be great also but I feel there isn't the capability to do a in query for array content in datastudio.
Many thanks

Related

Google Data Studio can't count user count for an analytics event

So i've an app that logs events to firebase/google analytics for instance lets say the event name is 'log_purchase'
I can use data studio and create a filter but now if i select my metric as
event count i can see a value but if i change it to 'Active Users' as in total number of unique users that triggered this event
It says no data, what am i doing wrong how can i see either active user count or event count that only logs users once
Turns out it needs at least around 40-45 users before the data studio shows them after that it starts to work properly.

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.

Possible to change Firebase callable Functions data on Front End?

I'm using Stripe and Firebase Function for payment. My current scenario for buying items in my app looks like the following.
Loading an Item, which is an firestore document with an Id and a price
User clicks on "Buy now for price", enters credit card information and confirems
I get a stripe source with an id, which to my knowledge contains information about the credit card
I call my firestore callable function and pass the stripeSourceId, itemID and the item.price
In my function I check if the user (from context) is authentiated, then I charge the user and save the bought item in the user data, to deisplay the item later
My concerns are the point 4. Is it possible for a user to hack my front end code in a way, so that after stripe returns the sourceId, the hacker would call the function with a different price or a different itemId to get a different item for another price? If that is the case, how could I fix this problem?
Anything you pass from the client to the server, can be changed by a malicious user. That's why you should never trust any data that comes directly from the server.
The solution is to only pass the itemID from the client, and have the server look up the price based on that. If the malicious user passes a different item ID, they'll just be buying a different item, but still at the price that you have set.
I highly recommend watching Five tips to secure your app from the Firebase Summit 2018 for more tips on securing your app.

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

Passing multiple labels in _trackEvent

Is it possible to pass more than one label in a single call of _trackEvent(category, action, label, value) so it could be used in report as a separate as a separate dimension or for filtering purposes?
My requirement is to track links (downloads) clicks for documents related with many meta-data parameters (document ID, product ID, category, language, revision etc.) and all those parameters should be available in customized reports.
Thanks in advance for help.
GA is not set up to track that granular of data about any one item.
And, since GA uses gif requests to send the data, you may bump up on the limit given the amount of data you want to send.
One way of tracking all the data you want to would be to push the data into a database via an ajax request.
If you have to use GA for this, you may be able to send multiple _trackEvents for each or a grouping of the meta-data items based on the document. A setTimeout should be used so GA has time to send the events. See Can I track multiple Google Analytics events at once?
In your case you would use:
function recordOutboundLink(link, category, action) {
_gaq.push(['_trackEvent', 'Click', 'Download', 'Whatever']); //could be mutlipush here
setTimeout('document.location = "' + link.href + '"', 100);
}
HTML
<a href="http://www.example.com/pdf.pdf" onClick="recordOutboundLink(this, 'Outbound Links', 'example.com');return false;">
Also, install Chrome and the Google Analytics Debugger. Look in the console (control, shift, j) for the event tracking processing.
If you don't see all of your events tracking there (they will be listed separately), then something is up maybe with the tracking code.
I've found in API docs that the same goal (tracking multiple key-value pairs sent in one _trackEvent request) could be achieved with custom variables:
_gaq.push(['_setCustomVar', 1, 'Items Removed', 'Yes'],
['_trackEvent', 'Shopping', 'Item Removal']);
The one important limitation of this approach is up to 5 maximum number of custom variables (or up to 50 extended custom variables for Premium GA Account)

Resources