I made an application showing a window while calling in certain case, using service component.
The window contains info of callee.
I wanna know how to track this window.
Few buttons would be added with functions - ex : sending sms.
And I just wanna count how many times this window has been shown.
I found this question - Android: can I use Google Analytics inside a Service?
But it seems it's about old version of GA.
And I failed to make that in my app.
(I tried :
public class view extends Service {
...
GoogleAnalytics mGA;
Tracker gat;
...
#Override
public void onCreate() {
super.onCreate();
mGA = GoogleAnalytics.getInstance(app);
gat = mGA.getTracker("UA-my-account");
Map<String, String> params = new HashMap<String, String>();
params.put("event", "test");
gat.send(params); )
Let me know how to make tracker work in my app with GA V3.
Thanks for any help.
I made it.
GA = GoogleAnalytics.getInstance(YourContext);
Tracker = GA.getTracker("Your UA-xxxxxxxxxxxxxxxxxxx");
1. Tracker.send(MapBuilder.createEvent("category","action","label",long type value).build());
2. Tracker.set(Fields.SCREEN_NAME, "SCREEN NAME");
Tracker.send(MapBuilder.createAppView().build());
now wait for a day for this to be shown.
Related
I've successfully added Analytics to an Android app and it is picking up session data just fine. However, I've also tried to track a specific event, but it does not seem to be sent to Analytics like the rest of the session data. I've followed the code suggested in the current Analytics documentation and still no luck, so I'm pasting here in the hopes that it's something obvious to more experienced folks. Many thanks in advance for any guidance.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_import);
user = getIntent().getStringExtra("user");
statusUpdateArea = (EditText)findViewById(R.id.dataStatusUpdateField);
progressBar = (ProgressBar)findViewById(R.id.progressBar);
progressBar.setVisibility(View.INVISIBLE);
welcomeMessage = (TextView)findViewById(R.id.WelcomeMessageTextView);
welcomeMessage.append(user);
// getting tracker & setting User ID field
AnalyticsApplication application = (AnalyticsApplication) getApplication();
mTracker = application.getDefaultTracker();
mTracker.set("&uid", user);
// build and send event
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("User ID")
.setAction("Data login")
.setLabel(user)
.build());
...
maybe you need use
mTracker = application.getTracker();
and
mTracker.setScreenName("yourscreenname");
Seems you are calling send before calling build .
Create a tracker with all the event info then call build and once done call send function .
Have worked on webtrends analytics product so I know a thing or two about analytics
I'm having trouble while implemented the new google tag manager lib.
Here is what I did:
I create a macro dataleyr
I set a rule for an event
I create a tag and set the universal analytics ID on it
I publish my container
Then I tried to use it in my app like this
TagManager mTagManager = TagManager.getInstance(this);
DataLayer mDataLayer = com.google.android.gms.tagmanager.TagManager.getInstance(this).getDataLayer();
ContainerOpener.openContainer(
mTagManager, CONTAINER_ID, OpenType.PREFER_NON_DEFAULT,
TIMEOUT_FOR_CONTAINER_OPEN_MILLISECONDS, new ContainerOpener.Notifier() {
#Override
public void containerAvailable(Container container) {
container.refresh();
// Save container for use by any other activities in the app.
com.appsconceptelite.appsconceptelite.testfunctionnalities.gtm.ContainerHolder.setContainer(container);
mContainer = com.appsconceptelite.appsconceptelite.testfunctionnalities.gtm.ContainerHolder.getContainer();
Utils.pushOpenScreenEvent(LearnActivity.this, "Learn Screen");
}
});
and the method I use to push event is
/**
* Push an "openScreen" event with the given screen name. Tags that match that event will fire.
*/
public static void pushOpenScreenEvent(Context context, String screenName) {
DataLayer dataLayer = TagManager.getInstance(context).getDataLayer();
dataLayer.pushEvent("openScreen", DataLayer.mapOf("screenName", screenName));
}
When I run this code in debug mode, I get the right container name and version but when I check in Google Analytics dashbord, I see no events like if no data have been pushed.
Can you tell me what I'm doing wrong?
Not sure if it will solve the issue but what tripped me is the old google analytics account that hasn't been created a "Mobile apps" account and no results would be seen on the account but were definitely sent out. Create a new "Mobile apps" property and try again.
I am trying to track the users that login into my app, but for no reason it only tracks the first screen.
Sometimes it track it with my package (com.company...), another times with the name Home Screen, and other times with "menu" (This one is what I put it)
I call this meted always I need to call a new screen.
public static void GATrackWithScreenName (String screen) {
Log.d(TAG, "Tracking "+screen);
Tracker tracker = GoogleAnalytics.getInstance(act).getTracker("UA-xxxxx-y");
HashMap<String, String> hitParameters = new HashMap<String, String>();
hitParameters.put(Fields.HIT_TYPE, "appview");
hitParameters.put(Fields.SCREEN_NAME, screen);
tracker.send(hitParameters);
}
Edit:
I also test this code, and some time works also with Map but no with Levels :S
Tracker easyTracker = EasyTracker.getInstance(act);
// This screen name value will remain set on the tracker and sent with
// hits until it is set to a new value or to null.
easyTracker.set(Fields.SCREEN_NAME, screen);
easyTracker.send(MapBuilder
.createAppView()
.build()
);
Also I need to wait like 30 secs in the screen to appear the connection, I got this app on iOS and it's instantly
Any ideas?
Try adding <integer name="ga_dispatchPeriod">10</integer> in your analytics.xml.
It worked for me!
I have sent much data by Tracker to Google Analycis as following codes:
tracker= GoogleAnalytics.getInstance(this).getTracker("UA-46451607-1");
HashMap<String, String> hitParameters = new HashMap<String, String>();
hitParameters.put("type", "appview");
hitParameters.put("screen_name", "My Screen");
tracker.send(hitParameters);
After sent these data to platform,where can i see the result?
I would like to see the value of "type " and "screen_name",but i dont know how to view them on web.
Check it.
import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.Fields;
import com.google.analytics.tracking.android.MapBuilder;
public class YourBaseActivity extends Activity {
#Override
public void onStart() {
super.onStart();
EasyTracker tracker = EasyTracker.getInstance(this);
tracker.activityStart(this);
String trackingId = "UA-ABCDEFG-I";
tracker.set(Fields.TRACKING_ID, trackingId);
String category = "Activity Lifecycle Callback";
String action = "onStart()";
String label = "Screen: " + getClass().getSimpleName();
tracker.send(MapBuilder
.createAppView()
.createEvent(category, action, label, 0L)
.build();
);
}
#Override
protected void onStop() {
super.onStop();
EasyTracker.getInstance(this).activityStop(this);
}
}
Then go to www.google.com/analytics/. Click Access Google Analytics.
And on the screen: tab Reporting (at the top panel) -> Real-time -> Events. And you'll see something like this (maybe not immediately, but within a few minutes):
Select category (at the bottom of the figure - here is CATEGORY_ACTIVITY_CALLBACK) and you'll see a number of actions:
But unfortunately I still have not found a way to see "not-realtime" data.
Sorry for my English
Follow these steps
open this link www.google.co.in/analytics/
Click on access Google Analytics button in the right side of the top most corner of this screen.
It will redirect you to your home screen. Here you can see your app name
Click on All Mobile App data link on home screen just below the title of your project
It will redirect you to App overview page.
It is where you want to be . Yo can see complete report and details of your app.
You may want to use Fiddler2 as a proxy to view the data.
open your Google Analycis account. You can check all the details related to the app. use this link
https://www.google.com/analytics/web/?hl=en#report/app-overvi/a46388977w77407404p80019218/
and Sign up the account.
When your offline to see the google analytics report follow the below steps.
Step 1. Go to Reporting
Step 2. Behavior and check Overview and Screens
Note: The total report will submit to google analytics once in 24hrs of time
I am trying to integrate kiip in my android app . I have downloaded the latest sdk and sample example from https://kiip.me/ developers site . Also ,I have created a new app in kiip.me site.
Everything is fine but the problem is , I am getting KPResource null so showing No Promo .
Here is the listner that I am using in onStart() method:
public void onStart() {
super.onStart();
// The Activity context has been created by now, so start a new session.
KPManager.getInstance().startSession(mStartSessionListener);
}
private KPRequestListener<KPResource> mStartSessionListener = new KPRequestListener<KPResource>() {
public void onFinished(KPManager manager, KPResource response) {
if (response != null) {
toast("Start Session Finished w/ Promo");
} else {
toast("Start Session Finished No Promo");
}
manager.showResource(response);
// Start retrieving user's location
new LocationHelper(ExampleApplication.this).requestLocationUpdates(mLocationListener);
}
Here the response is always null , so getting the message : Start Session Finished No Promo . If anyone has got similar problem then please share your views.
Thanks in advance.
Have you enabled promos for test devices in the dashboard on https://kiip.me?
It sounds like it could be a settings issue on the server side. Try logging in and switching promo frequency and adding your test device.
Finally, the issue has been resolved. I think the problem was with my device , when I tested it next day with some other device, It worked for me.