2
votes

I created a custom dimension and metric and am trying to fill it with data from an Android app. I created a new dashboard of a table using the custom dimension (user id which is declared at the user scope) and the custom metric (bad attempts which is at the hit scope level), but the dashboard says that there are no values to show. Maybe I'm sending the data in a wrong way?

This is how I do it:

public static enum CustomDimensions
{
    USER_ID(1);

    private int value;

    CustomDimensions(int numVal)
    {
        this.value = numVal;
    }

    public int getValue()
    {
        return value;
    }
};

public static enum CustomMetrices
{
    BAD_ATTEMPTS(1);

    private int value;

    CustomMetrices(int numVal)
    {
        this.value = numVal;
    }

    public int getValue()
    {
        return value;
    }
};

public static void SendCustomEvent(Activity act, CustomDimensions cd, String dimensionValue,
        CustomMetrices cm, int metricValue)
{
    Tracker tracker = getGoogleAnalyticsTracker(act);
    tracker.send(new HitBuilders.EventBuilder().setCustomDimension(cd.getValue(), dimensionValue).build());
    tracker.send(new HitBuilders.EventBuilder().setCategory("customCategory").setAction("customAction")
            .setLabel("customLabel").setCustomMetric(cm.getValue(), metricValue).build());
}

and the call itself:

SendCustomEvent(this, CustomDimensions.USER_ID,
                        "1", CustomMetrices.BAD_ATTEMPTS, 1);

In the behavior section of the report I do see the events with customCategory and so on, but not any value of the dimension or metric.

2
How long did you wait after inserting the data? Takes 24 -48 hours to see data in standard reports.DaImTo
but if I see the events with the custom category, custom action and custom label like I sent in my code then doesn't it mean that enough time has passed?Yonatan Nir
Not always its random what information shows up wand when. Note: remember its against terms of service to track user specific information user_id may be a bad idea.DaImTo
As I understand, it's only against the terms of service if I'm tracking something that can personaly identify the person like first or last name doesn't it? There is even a guide of how to store the user id in the tracker. And there got to be a way that I can track an event/users..Yonatan Nir
Yes but you can't get the user_id that you track out of the system its only used for processing. Any information that could be used to track back to a user is against terms of service.DaImTo

2 Answers

1
votes

It seems that regular events are updated sooner than custom dimensions and metrices. I could see that a "customCategory" event was created but nothing was shown in the custom dimension value. After another 24 hours (48 total), I got the data and can now see it.

0
votes

It looks like you are sending two independent events (two calls to tracker.send). One with only custom dimensions and one without custom dimensions. The first event is invalid as it is missing required event category and action so Analytics will ignore it. The second is valid event but its missing the custom dimensions. You should send only one event instead:

tracker.send(new HitBuilders.EventBuilder()
    .setCategory("customCategory")
    .setAction("customAction")
    .setLabel("customLabel")
    .setCustomMetric(cm.getValue(), metricValue)
    .setCustomDimension(cd.getValue(), dimensionValue)
    .build());