Google analytics custom screen names in Easy Tracker - android

I have an application with a reused activity (its used for different purposes so just tracking the activity name would not help me, thats why I want to define the screen name manually while still using the EasyTracker. My code looks like this:
EasyTracker t = EasyTracker.getInstance(this);
t.set(Fields.SCREEN_NAME, screenName);
// MapBuilder map = MapBuilder.createAppView();
// map.set(Fields.SCREEN_NAME, screenName);
// t.send(map.build());
t.activityStart(this);
I got these information from https://developers.google.com/analytics/devguides/collection/android/v3/screens
I dont want to do this without the EasyTracker because I didn't find any information what exactly happens in the methods activityStart() and activityStop() of the easy tracker so I cant reproduce this behaviour with a custom tracker and I think the inforation which is collected in the activityStart() method in addition to the screen name is also very usefull. So has someone experience with defining custom values in the easy tracker? Is it a good way to do it this way or is there a better solution?

If anyone comes across the question, the as per the v3 of the Google Analytics SDK,
EasyTracker.getInstance(this).activityStart(SCREEN_NAME); // Add this method.
where SCREEN_NAME is the user defined constant for the reused Activity.
Using custome screen names instead of the default ones i.e the full qualified path name of the Activity
doesn't cause any issues in data collection.
Recommendation, Use Google Tag Manager for your Tracking purpose, it provide you better flexibility like changing the UA property ID in future as well the screen names to be sent to Google Analytics. Read more # Developer Guide For Android

Related

Simple Google Analytics for Android

I am using a simple Google Analytics code. When I look the real-time users on Google Analytics, I can see "1 active user now". There is no problem, but I am suspicious that this code will give wrong results on Google Analytics because When I look their guides, their implementations is different. Can this code give wrong result on Google Analytics?
My Code:
Declaration in MainActivity
public static GoogleAnalytics analytics;
public static Tracker tracker;
Implementation in onCreate
analytics = GoogleAnalytics.getInstance(this);
analytics.setLocalDispatchPeriod(1800);
tracker = analytics.newTracker(unitid);
tracker.enableExceptionReporting(true);
tracker.enableAdvertisingIdCollection(true);
tracker.enableAutoActivityTracking(true);
No more code, just 6 lines.
If there is no problem for this code, why their guide is complex?
Note: There is no problem now, but I am suspicious about future.
This is, indeed, close to the simplest implementation possible.
The problems with it, however, is that:
GA library has hardcoded triggers that are qualified to be "screenviews". While it may be sufficient for very simple apps, it poorly handles layered views logic that is commonly used in more complex apps.
GA library has to send screen identifiers. And there's little to none of what it can use for that. So what it does is it tries to pull class names as identifiers for screen names when no explicit name is set (which is the case in automated tracking). This results in the data being hard to read.
Personally I've never seen auto activity tracking being used in production. Maybe it makes sense to be used by the developers to improve exceptions logging in Firebase, but the data is way too inconsistent and hard to decode to be flexibly use for business reporting.
You achieve a lot better tracking quality when you set each screenname explicitly. That is the best practice.

How to provide content to be shown on Google-Now-On-Tap?

Background
I work on an app that can answer to certain queries (phone number queries, and maybe others).
Google introduced a new feature on Android 6 , called "Google Now On Tap" (AKA "Assist API") , which allows the user to query about things that are shown on the screen (triggered by long-click on home button or by saying something) without the need to type anything.
Google provided a developers tutorial for it, here
The problem
I can't find any code snippet to show how to prepare the app for it.
Only thing that I've noticed is that I can extend from Application class, and add OnProvideAssistDataListener inside , and register to it.
But, it opens a lot of questions about how to do it.
Sadly, because this topic is so new, I can't find almost anything about it, so I'd like to ask the questions here.
The questions
1) Is there any sample or at least a more explained tutorial for this new feature?
2) It is said in the docs:
In most cases, implementing accessibility support will enable the
assistant to obtain the information it needs. This includes providing
android:contentDescription attributes, populating
AccessibilityNodeInfo for custom views, making sure custom ViewGroups
correctly expose their children, and following the best practices
described in “Making Applications Accessible”.
Why and how does it work with the accessibility features of the app? What does it have anything to do with exposing child views (or views at all)? How could it even be about views, if the app doesn't run yet (because the feature is activated on any app, anywhere).
What I think is that this is called only if the foreground app is my app, but if it is this way, how can I actually offer queries that appear for all apps, depending on what the input is?
3) Does the class that extends from Application supposed to implement OnProvideAssistDataListener ? If so, why does it need to register to it? If not, how could it be that Google-Now-On-Tap works with it? It can't just open all apps that have such a classs, and see if they register...
4) The docs have a sample snippet which I didn't understand:
#Override
public void onProvideAssistContent(AssistContent assistContent) {
super.onProvideAssistContent(assistContent);
String structuredJson = new JSONObject()
.put("#type", "MusicRecording")
.put("#id", "example.comhttps://example.com/music/recording")
.put("name", "Album Title")
.toString();
assistContent.setStructuredData(structuredJson);
}
What does the new feature do with each key? Is it used by the app, or Google-Now-On-Tap ? What are my options about it?
Is this where I define if my app can handle the content that the feature suggests me? Is AssistContent supposed to be the input that I look at, and decide if my app can handle it or ignore it?

How to set tracking ID after tracker created in Google Analytics v4 for Android?

In the Google Analytics SDK v4 for Android, the documentation says that you can create a tracker without initializing it with a tracking ID first:
GoogleAnalytics.newTracker() says:
If the trackingId is empty, you can still get a tracker, but you must
set the tracking id before sending any hits. This is useful if you do
not know the tracking id at the time of tracker creation, or if you
want to use the same tracker instance to track multiple tracking ids.
The class overview of Tracker says:
A Tracker must be initialized with a tracking id of an app profile
before you can send any hits. You can change the id to send hits to a
different profile.
What method do you call to set the tracking ID after the tracker has been created?
Motivation
In the v3 version of the Android SDK, the configuration files could be split up, and I could use resource merging to define common values such as the tracking ID in src/main/res/values/analytics.xml and include debug attributes such as ga_dryRun in src/debug/res/values/analytics.xml.
But the v4 SDK now reads the configuration from res/xml which doesn't support resource merging AFAICT. I would like to define the tracking ID in one place, either Java or in XML, but also have the flexibility of different configuration files for different build variants.
Currently it is not possible to set the trakcing id after the tracker has been created. A HACKY way to do it is to use the Tracker.set() method with key = "&tid" and value as the tracking id.
Thanks for describing your motivation though. We'll keep that in mind for future releases.
CAUTION: The reason tracking id can only be set during creation is because tracker objects contain a lot of state data. It is highly recommended that the tracking id be not changed after the initial creation.
PS: The hacky method will be supported for the foreseeable future but if you decide to use it, please confirm that the data can be seen in realtime reports before publishing the app.

Google Analytics - Tracking a view with multiple custom dimensions values

I'm trying to add more data to my Google Analytics report regarding the use of my Android app.
I started using custom dimensions since yesterday and didn't get any results yet and I want to make sure I'm doing it right.
I want to tie a page view with additional information to be sent with it, and that's why I'm using custom dimensions. In the onCreate method of a specific activity I'm doing this -
Tracker tracker = EasyTracker.getTracker();
tracker.setCustomDimension(1, 128));
tracker.setCustomDimension(2, 2));
tracker.setCustomDimension(3, 45));
EasyTracker.getTracker().trackView();
I've set my custom report to work by the Screen Views metric, and by one of the dimension Id's from above.
Will all of this data be sent along with the trackView command? Because I still can't see any data from yesterday.
Thanks!
It works. This time I needed to wait about 2 days for the data to appear.
Now I need to figure out how to show the data from all these dimensions at once, but I guess this fits another question.
I don't have any experience with GA tracking using the android sdk api but I did find this page in the GA documentation. In the code examples they use the following as the trigger:
tracker.sendView();

Google Analytics Android SDK custom vars not registered/not showing?

So I'm still mucking around with this Google Analytics SDK. According to this, I should be able to send custom vars with a visitor scope that include the app version, and the phone model.
Using tracker.getVisitorCustomVar(i) I can see that the information is indeed stored, and the log shows NetWorkRequestUtil/ConstructPageviewRequestPath with a message that contains the custom vars.
But it does not show up in the analytics report along with the other tracking information. I thought I would find it under Visitors->Custom Variables, but that only says
There is no data for this view.
Where can I see the custom variables? :(
How long ago did you incorporate the custom vars? Analytics is not realtime, there can be an --i think-- 24 hour gap?
I'm doing this, and it works for me. I'm assuming you do get other data, so your initialisation and 'dispatching' of the tracker is correct?
You can set your customvar like so (as I imagine you are doing allready).
tracker.setCustomVar(TRACK_SLOT_AUTH, TRACK_CVAR_AUTH, isAuth, TRACK_SCOPE_SESSION);
(using global vars to be sure not to override already used slots here, but the intention should be clear)
The data shows up under Visitors->Custom Variables
Custom variables have been replaced by Custom Dimensions and Metrics.
https://developers.google.com/analytics/devguides/collection/android/v2/migration#update-methods

Categories

Resources