Google Analytics version 3 - How to apply it correctly?
Posted
by
ephramd
on Stack Overflow
See other posts from Stack Overflow
or by ephramd
Published on 2013-10-20T21:50:40Z
Indexed on
2013/10/20
21:53 UTC
Read the original article
Hit count: 227
I've added google analytics to my app with the intention of obtaining information about the screens you and send custom events.
I am obtained duplicate content ... Also I get different results: "com.package.app.MainScreen" - 300 views and "Main Screen" - 200 views
I am interested to get only follow up with the custom name of the activity and not the package. And in any case, because both show different results?
public class MainScreen extends Activity {
private static final String GA_PROPERTY_ID = "UA-12345678-9";
private static final String SCREEN_LABEL = "Main Screen";
Tracker mTracker;
EasyTracker easyTracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_screen);
mTracker = GoogleAnalytics.getInstance(this).getTracker(GA_PROPERTY_ID);
mTracker.set(Fields.SCREEN_NAME, SCREEN_LABEL); // For Custom Name from activity
mTracker.send(MapBuilder.createAppView().build());
easyTracker = EasyTracker.getInstance(this); // Analytics Events
...
easyTracker.send(MapBuilder.createEvent("MainScreen", "Play", category.get(1), null).build()); //AnalyticsEvents
...
}
@Override
public void onStart() {
super.onStart();
EasyTracker.getInstance(this).activityStart(this);
}
@Override
public void onStop() {
super.onStop();
EasyTracker.getInstance(this).activityStop(this);
}
}
And analytics.xml:
<?xml version="1.0" encoding="utf-8" ?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes">
<!--Replace placeholder ID with your tracking ID-->
<string name="ga_trackingId">UA-12345678-9</string>
<!--Enable automatic activity tracking-->
<bool name="ga_autoActivityTracking">true</bool>
<!--Enable automatic exception tracking-->
<bool name="ga_reportUncaughtExceptions">true</bool>
</resources>
© Stack Overflow or respective owner