Attach custom metric to HitBuilders.TransactionBuilder in Android Analytics v4 - android

How can I attach a custom metric value to HitBuilders.TransactionBuilder in the following fashion? I want to associate a transaction with a value.
tracker.send(new HitBuilders.TransactionBuilder()
.setOtherAttributes(...)
.setCustomMetric(1, 10)
.build());
The rest of the data are successfully sent, but the custom metric is always 0.

It seems your code is correct. You can try to setCustomDimension instead of setCustomMetric, you only have to transform float to string.

Your code is correct. What you need to check is the server side reports you build.
Make sure you created a Custom metric in Admin - Custom Definitions - Custom metrics. Once created, custom metrics will initially appear with a 3 to 4 hours delay on the server. Give them some time to appear there. Finally, you need to create a report to see the result. Make sure you choose the right time intervals and don't add too many metric and filters, otherwise you won't see data. Make first reposts as simple as possible. I hope this helps.

The problem was with that the scope of the custom metric was not Hit and that I was looking at a custom report widget matched by Product. The value appeared when I changed the column.

Related

GAv4 for android: can deviceCategory value be overriden?

I need to manually override the value that Google analytics sends for the deviceCategory predefined user dimension (let's say that instead of "mobile", I need It to be "android phone"). But I couldn't find anywhere in the SDK documentation if this is possible or not, and how to do it, other than using a custom dimension, which is not what I want.
Is this even possible?
You can definitely override some of the default dimensions as shown here You could probably follow the same algo to override other dimensions.
Another thing I'd try is looking at the network request and seeing if deviceCategory can be overriden by setting it as an event propery.
Finally, you can always override any field if you use GTM inbetween, but it's kind of an overkill. You don't want to use it just to slightly shift the field value.
I would generally suggest either not touching it at all if you're just renaming it for the comfort of the analyst or using a custom dimension/event propery to track it if it's a separate datapoint.

Contents of Bundle in Firebase Analytics Event not showing in dashboard

I have the same issue as this thread but the answer is outdated and seems to be incorrect. It refers to a button "Add event parameters" which is not present in the current version of firebase.
I want to view the content of the bundle for the event on my Firebase event page. Here is my event page on firebase:
I've followed this firebase tutorial and here is my code:
private fun sendLogging(context: Context, source: String, logMessage: String) {
val bundle = Bundle()
bundle.putString("LOG_MESSAGE", "$source $logMessage")
FirebaseAnalytics.getInstance(context).logEvent("PUSH_CONTENT_NOT_RECEIVED", bundle)
}
The source and logMessage contain precise information about what went wrong and I need to view this. It should show up?
EDIT:
I went to "Custom Definitions":
And I've added the event:
I discovered that only from that moment it started collecting information. But I do not see the information that I've logged anywhere. Where is it?
Adding LOG_MESSAGE to the Custom Definitions as an event-scoped custom dimension is the correct direction. You can follow the "Create a custom dimension" on the "[GA4] Custom dimensions and metrics" page.
GA4 limits the length of event parameter names & event parameter values. See [GA4] Collection and configuration limits for more information. In your case, LOG_MESSAGE is the event parameter's name (limited to 40 characters), and the runtime value of "$source $logMessage" is the event parameter's value (limited to 100 characters).
If "$source $logMessage" needs to be more than 100 characters, you could make the source and logMessage separate event parameters. For example, you'd update your code to:
bundle.putString("LOG_MESSAGE_SOURCE", source)
bundle.putString("LOG_MESSAGE_VALUE", logMessage)
Then, you would register LOG_MESSAGE_SOURCE and LOG_MESSAGE_VALUE as two event-scoped custom dimensions, and each would be limited to 100 characters individually.
Thanks,
Brett Sneed
The Google Analytics Team
Try adding the LOG_MESSAGE under Custom Definitions as an event or user custom dimension, this now available from the menu on the left in the Analytics section.
Custom Definitions Image

Android Creating custom dimension in google analytics

I want to set user level custom variables using google analytics in android
I can see there is lack of documentation and demo for this I want to know how to set custom variable using GA and I am referring to following link
https://support.google.com/analytics/answer/2709828#scope
but it is not helpfull at all code given in it is not in java and very confusing
If anyone has proper sample related to it please share
And it is not clear at all how much time it will take to reflect these changes on GA dashboard there is no clarity while using google analytics.
Also there a sample a code given
// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("Home Screen");
// Send the custom dimension value with a screen view.
// Note that the value only needs to be sent once.
t.send(new HitBuilders.ScreenViewBuilder()
.setCustomDimension(1, "premiumUser")
.build()
);
Now can anyone explain what is value 1 stands and it comes from where for in above call and why I need to call setScreenName
Also I have referred below link as well but does not give any clear idea
https://support.google.com/analytics/answer/2709829?hl=en&ref_topic=2709827
Also I tried to create custom variable I observed that one custom variable Demographic is already there I guess it is default created by GA so now my custom variable will start with index 2 or 1 that is also a confusion.
Custom Dimensions and metrics are identified by an index: 1 to n. The first Custom dimension you create will have an index of 1. Before you can send custom dimension and metric values to Analytics, they must first be defined in an Analytics property in the Analytics UI or through the Management API. Each Analytics property has 20 available indices for custom dimensions, and another 20 indices available for custom metrics.
The sample you used is sending a screen view hit (hence why it is setting the screen name) and sending a value to the first custom dimension. However you can send the information on any event type you'd like. For example:
// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
// Build and send an Event.
t.send(new HitBuilders.EventBuilder()
.setCategory(getString(categoryId))
.setAction(getString(actionId))
.setLabel(getString(labelId))
.setCustomDimension(1, "premiumUser") // Set the first custom dimension value to premiumUser for this event.
.build());
When you query for the value of the custom dimension with the Analytics Reporting API you will identify the custom dimension by index aswell, ga:dimension1.
Apart from registering in Android
Bundle().apply {
putString("Business", "NONE")
putString("PageVertical", "NONE")
FirebaseAnalytics.getInstance(context).setDefaultEventParameters(this)
}
Do not forget to register at Google Analytics UI
Custom parameters: Custom parameters can be used as dimensions or metrics in Analytics reports. You can use custom dimensions for non-numerical event parameter data and custom metrics for any parameter data better represented numerically. Once you've logged a custom parameter using the SDK, register the dimension or metric to ensure those custom parameters appear in Analytics reports. Do this via: Analytics > Events > Manage Custom Definitions > Create Custom Dimensions
Read more

How do you pass Custom Dimension values to Google Tag Manager in Android NOT the web

I am able to pass events to google Tag Manager v4 but the custom dimensions are not set. I have not been able to find ANYTHING on examples how to do this. The custom dimensions are setup correctly.
the code I'm using is:
DataLayer mDataLayer = ContainerHolderSingleton.getDataLayer();
mDataLayer.pushEvent("clip-start",DataLyaer.mapOf("Network","network value here"));
It should be this simple. I've setup the custom dimensions to be Custom Dimension index 1, in the admin it's setup as index 1.
Doesnt' help that googles sample code doesn't tell me much either: This is the generated code that is generated when I input the custom dimesnion in the admin. What is "tracker", or Fields.. they dont tell me which import will work with this.
String dimensionValue = "SOME_DIMENSION_VALUE";
tracker.set(Fields.customDimension(1), dimensionValue);
So ultimately, how do I pass the custom Dimension values through the data Layer to GTM.
It is probably because you may not have added custom dimensions into your google analytics tag in tag manager. Add the custom dimensions with parameters with values. The ids should match the ones in analytics.
Hope that helps
The way I solved this was to use the GoogleAnalytics Tracker like this:
tracker.set("&cd1", "new video title");
tracker.set("&cd2", "vidoe type");
tracker.set("&cd3", "access");
&cd1, &cd2 etc is the way these constant fields are passing custom dimensions to the back end.
Make sure you double check the sample code for reusing and downloading a container. I had mucked with it and that was stopping me from getting the new container, thus also not getting new values. Copy the sample code verbatim.

Events not firing in Google Analytics via Google Tag Manager

I have been searching high and low for an answer on this and I am completly dumbfounded.
I am implementing simple click and page tracking in my Android app using GA, running this through GTM. All my "Screens" are visible in realtime in GA but I can't get "Events" to appear at all.
Well actually I can but the behaviour seems very bizarre. If I do not include a "Label" and a "Value" I can see the events appear. However if I add them (either as just a constant or a data layer variable) all events stop. I have confirmed the variables I want in "Label" and "Value" are coming through as I made a container with those values as "Category" and "Action" and could see them as expected in real time.
This leads me to think the app side implementation is perfectly fine but there is an issue with my tag in GTM. (Obviously not the Trigger as that too works when expected).
Ideally I would like to do something like this (the variables are data layer variables):
But this doesn't work. I see no Events.
The Event Value should be a number, not a string. Shuffle the fields, for example - Action - Click on: {{GTM - Click Target}}, Label - {{GTM - Click Value}}, and leave the value empty, this will fix your problem.
Make sure, you have correctly setted up Click listener.
Enable when defines when is listener available and where is applied to the all DOM elements.
Fire ON defines conditions, so in your case it could be {{event}} equals gtm.click or {{event}} equals gtm.linkClick .
This is the most common pitfall when setting listeners

Categories

Resources