Following this guide I've added GA to my app and it works just fine. To send hits, I use the following code:
getGaTracker().set(Fields.SCREEN_NAME, "Screen Name");
getGaTracker().send(MapBuilder.createAppView().build());
But what if I want to set more parameters to this Tracker? If you check Fields.class, you will se lots of parameters that can be set.. like in hitParameters.put(Fields.HIT_TYPE, "appview");, can I set any arbitrary value for HIT_TYPE? Where will this appear in my stats, and what are the other fields for?
I also want to find out if I can add more parameters to 'getGaTracker().set()', in a way to add more logging levels like when logging Events...
Again from the DevGuide we have this snippet:
Tracker t1 = GoogleAnalytics.getInstance(this).getTracker("UA-XXXX-1");
// Trackers may be named. By default, name is set to the property ID.
Tracker t2 = GoogleAnalytics.getInstance(this).getTracker("altTracker", "UA-XXXX-2";)
So the Property ID isn't the only possible parameter for instantiating a Tracker. It would be great to have some docs do check all uses for it.
The only thing I found so far is this page
Related
I would like to pass along an array of bundles to FirebaseAnalytics as described here but FirebaseAnalytics.Param does not contain an ITEMS value. In fact, it only seems to contain a subset of the values it should contain as shown here:
I have firebaseanalytics version 17.4.4 and I tried to fill in the Param.ITEMS constant value myself ("items" according to the docs) but DebugView shows a firebase error (20 - Event array parameter name is invalid). All other events and parameters seem to work just fine according to DebugView and I found nobody with similar problems. Does anyone have any ideas as to why I only see a subset of the parameters?
Make sure you perform a Gradle sync, as FirebaseAnalytics.Param.ITEMS is definitely available in v17.4.4.
Here it is in my project, note the version number in the bottom right:
If you're still having trouble, mouseover one of the options in your dropdown and it should show you the version being used.
I found how use GTMv4 for GA and GTMv5 for FA, but no any information for v5+GA (for web side little bit more information).
is the correct replacement(in each case)?
Case 1:
Bundle params = new Bundle();
params.putString("screenName", screenName);
params.putString("screenID", screenID);
df.logEvent("openScreen", params);
from
getDefaultTracker().setScreenName(screenName);
getDefaultTracker().send(new HitBuilders.ScreenViewBuilder()
.setCustomDimension(3, screenID);
Case 2:
Bundle params = new Bundle();
params.putString("category", getCategory());
params.putString("action", getAction());
params.putString("label", getLable());
params.putInt("value", 0);
params.putString("name", "start");
df.logEvent("event", params);
from
getDefaultTracker().send(new HitBuilders.EventBuilder()
.setCategory(getCategory())
.setAction(getAction())
.setLabel(getLable()))
.setValue(0)
.setCustomDimension(2, "Start")
.build());
So, how need configure tag? In manual for v4->ga we have Variable type "Data Layer Variable".What is analog for GTMv5?
Also, where I could get all key for bind data?
img from manual v4, but i can't find similar information in v5
From manual:
Event Name: The value is set to "eventNameXYZ" when the following code in your app is executed:
Android:
FirebaseAnalytics.getInstance(mContext).logEvent("eventNameXYZ", null);
but how to set value? I can create only "new variable" with "Title". Or need set name equal key, e.g. "eventNameXYZ"?
Secondary Question:
It possible to use GTM+Firebase for save data in local storage?
Update
aghhhr, why divided radio buttons? + Custom parameter looks like hint :(
If you're trying to send Universal Analytics hits from firebase, then case 1 and case 2 both look correct, though you might want to be more specific about the name of the event in case 2. If the event you're recording is equivalent to one of the suggested Firebase Analytics events, then consider using that as the event name, instead of the more generic name event.
To setup a GA tag to fire for these logEvent calls, you'll want to create "Event Parameter" variables for each of the event parameters you're using. For example, to capture the screen name you're including in case 1, you would setup an EventParameter like this:
For the tag setup, you just use the screenName variables as the values in fields to set, event variables, or custom dimensions. For screen views, be sure to provide a screen name, as it's required for a screen view.
To trigger the Universal Analytics tag, you would setup a trigger for event name. In the first case, the trigger setup would look like this:
.
And to answer your second question, You can use Firebase user properties to store data in local storage, report it to firebase, and make it available to GTM via the Firebase User Property variable type.
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
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.
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.