Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 341
amodkanthe Avatar asked Jun 01 '16 05:06

amodkanthe


People also ask

How do I set custom dimensions in GA4?

In GA4, creating a custom dimension involves the following two steps: Sending an event parameter along with an event. Registering the logged event parameter as a custom dimension in the user interface.

How many custom dimensions can you have in Google Analytics?

To set up your custom definitions you need to go to your analytics account >property settings > custom definitions. Keep in mind however there is a limit of 40 custom definitions, that is 20 metrics & 20 dimensions, so try to make sure you pick things that actually benefit the way you study your analytics account.


1 Answers

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.

like image 157
Matt Avatar answered Nov 15 '22 05:11

Matt