Google Analytics Easy Tracker Issues - android

I am trying to integrate Google Analytics on my Activities.
As per the google docs I read up on EasyTracker and added EasyTracker.jar to my libs and referenced the same, extended my Activities from "TrackedActivity" / "TrackedListActivity"
Also made an entry in the strings.xml file located under values
<string name="ga_api_key">UA-xxxxxxxx-x</string>
But whenever I log into Google Analytics I don't see any tracking displayed there.
Where have I gone wrong?

Add another string:
<bool name="ga_debug">true</bool>
And then check logcat to see any information from the Analytics library.

Google Analytic 1st time appear on website after about 24-48 hours. So if you are waiting for analytic after implementation then just wait for 48 hours.

did you give the following uses permission.
<uses-permission android:name="android.permission.INTERNET" />
GoogleAnalyticsTracker tracker = GoogleAnalyticsTracker.getInstance();
tracker.start("your analytics code", this.con);
tracker.setCustomVar(1, "Medium", "Mobile App");
tracker.trackPageView("ur activity name");
tracker.dispatch();
tracker.stop();

Related

Unable to make Firebase work for a non Gradle build: Missing google_app_id. Firebase Analytics disabled

The app I am working on has a very customized build process. It's not possible to use gradle to build my app. It's not ideal, but I cannot change anything about it.
Nevertheless, I want to use Firebase Analytics in my app. In included the modules firebase-core, firebase-common, firebase-analytics, firebase-analytics-impl, firebase-iid, firebase-iid-interop, firebase-measurement-connector, firebase-measurement-connector-imple, play-services-measurement-base and play-services-measurement-api. I also added the following strings to my strings.xml, with the values I found in the google-services.json for my Firebase project:
<string name="google_app_id" translatable="false">xxx</string>
<string name="gcm_defaultSenderId" translatable="false">xxx</string>
<string name="default_web_client_id" translatable="false">xxx</string>
<string name="firebase_database_url" translatable="false">xxx</string>
<string name="google_api_key" translatable="false">xxx</string>
<string name="google_crash_reporting_api_key" translatable="false">xxx</string>
<string name="project_id" translatable="false">xxx</string>
(as described here) and removed the FirebaseInitProvider from the AndroidManifest.
In my apps Application class onCreate() I do:
FirebaseOptions.Builder builder = new FirebaseOptions.Builder()
.setApplicationId(getString(R.string.google_app_id))
.setApiKey(getString(R.string.google_api_key));
FirebaseApp.initializeApp(this, builder.build(), "[DEFAULT]");
No issues so far. When the above code is executed, I get a debug log message saying:
FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
All good, I didn't include the auth module. I don't need it for my app. When I call FirebaseAnalytics.getInstance(adblockSettingsTextView.getContext()).getFirebaseInstanceId() it returns a String value, so I assume the initialization was successful.
Now every time I want to log an event like this
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "Dashboard");
FirebaseAnalytics.getInstance(this).logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
I see the an error in my log saying Missing google_app_id. Firebase Analytics disabled. See https://firebase.google.com/docs/android/setup. On top of that, I don't see any active users in the Firebase Analytics dashboard.
I read all documents I could find and tried my best to find the cause for this problem. But right now I have no more ideas what I can check or change to make it work. Help would be highly appreciated. Thanks!
In case someone else runs into the same issue, I leave the answer I got from the Firebase Support here:
Google Analytics for Firebase (GA4F) doesn't support dynamic
initialization. Our engineers are checking the possible solutions to
support this. It's just that we still haven't found a definite
timeline as to when (or if) this will be available.
GA4F will not work without the google-services.json file (or Gradle on
your end). Even though you can initialize the FirebaseApp dynamically
through code, GA4F will not recognize this and will only result in the
error message you are seeing. The scenario you are getting is only
specific to Google Analytics for Firebase. However, you can still use
other products like Firestore, Realtime Database, Storage even if you
are not using Gradle plugin.

App Speed Integration - Google Analytics

I want to integrate AppSpeed Parameter in my Android Application, for that I have used the following code:
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
// Build and send timing.
t.send(new HitBuilders.TimingBuilder()
.setCategory(getTimingCategory())
.setValue(getTimingInterval())
.setVariable(getTimingName())
.setLabel(getTimingLabel())
.build());
and called the above sendmethod with appropriate methods, but App Speed section of my portal is still blank. How it will show the data ??
Thanks
Use this:
t.sendTiming(loadTime, "resources", "high_scores", null);
To have in mind that the tracks of timing (App speed) sometimes are not refresh immediately like Events and Screenviews in Google Analytics Console. In my case, I had to wait a few hours to see the results. Also check to have in AndroidManifest.xml the following:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Google Analytics not updating

I've incorporated the latest Google Services library into my app, and have added screen tracking using the code below:
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker t = analytics.newTracker(R.xml.global_tracker);
t.setScreenName(full_event);
t.send(new HitBuilders.AppViewBuilder().build());
My global tracker xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="ga_sessionTimeout">300</integer>
<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">false</bool>
<!-- The following value should be replaced with correct property id. -->
<string name="ga_trackingId">[redacted]</string>
where I've used the "all apps" property tracking code.
I send a screen name update manually each time a user visits a particular screen in the app.
The real time updates show fine in the Google Analytics web page, but for some reason the historical reporting is not working. I've looked online and there is a suggestion that it can take 48 hours to show when you first set it up. However I started sending analytics data on Monday and it's now Saturday and nothing is showing up.
Am I doing something wrong or should I just give it more time?
I don't have that many users of my app (a few hundred perhaps). Could it be that Google needs a certain volume of data before it shows any statistics?
Any thoughts gratefully received.
Andrew
I worked out what was wrong. My code above creates a new tracker every time a screen view is to be sent whereas you're only supposed to create one per instance of the app.
I also modified it so that it was sending back screen views based on each specific app (rather than the all apps code) as well as including code in my onStart and onStop methods to enable tracking of the app itself as well as exception handing etc.
All working now.

how to create Google Analytics SDK v4 for Android ecommerce_tracker.xml For tracker

I don't have any sample code for google Analytics even after installing google_paly_services library.
After following this link
https://developers.google.com/analytics/devguides/collection/android/v4/
i have been stuck in ecommerce_tracker.xml and PROPERTY_ID . I am not getting how to define it.
PROPERTY_ID in your application class is "tracking id" value which you get when you create a google analytics account/ entry for your app.
And there is a sample xml configuration file for the "ecommerce_tracker.xml" in \extras\google\google_play_services\samples\analytics\res\xml where you have to enter ga_tracking id same as you get from above.
Hope this helps!

How to use tracking id of google analytics in android app?

I am trying to integrate google analytics with my android app. I followed the steps in the following link:
https://developers.google.com/analytics/devguides/collection/android/v3/#manifest
Then i tried the look at the statistic of my app, but it seems like analytics is not working, i must have done something wrong. The problem is, in those steps we do not make use of the tracking id, and in google analytic's web site, it says that
Download the Google Analytics SDK for Android or iOS and implement the tracking code,
including this tracking ID.
What does it mean to "implement the tracking id"? What should i do about this can anyone help me?
Thanks
Use this:
Tracker tracker = GoogleAnalytics.getInstance(context).getTracker(ga_trakingId);
Then you can SET some variables, that will be send to GoogleAnalytics:
tracker.set(Fields.APP_NAME, "Best Android Application");
tracker.set(Fields.APP_VERSION, "1.0");
To SEND some info, events:
tracker.send(MapBuilder.createEvent("UX", "App Launch", null, null).build());
You must watch Behind the Code: The Google Analytics v3 Mobile SDKs, all info from there.
Update 1
Google Analytics API v4 you should create google-services.json file from here and then you can use:
public Tracker getTracker() {
return GoogleAnalytics.getInstance(this).newTracker(R.xml.global_tracker);
}
And then you canuse it like this way:
getTracker().setScreenName("SomeScreenOrActivityName");
getTracker().send(new HitBuilders.ScreenViewBuilder().build()); // send screen name
The new process generates a file by Google which is called GoogleService-Info.plist.
This file contains (key, string) and one of them is:
<key>TRACKING_ID</key>
<string>*YOUR TRACKING ID*</string> // Auto generated by GAI
Just open the file and confirm that this is your tracking ID.

Categories

Resources