3

I want to use google analytics within a fragment for tracking screen views. I don't understand where we should allocate a Tracker instance. The doc on manual screen tracking leaves us with this example:

/**
 * Within an Activity or Fragment
 */
@Override
public void onStart() {
    super.onStart();
    ... // Your other onStart() code.
    myTracker.sendView("Home Screen"); // Where myTracker is an instance of Tracker.
}

https://developers.google.com/analytics/devguides/collection/android/v2/screens

Where is "myTracker" defined? What is its lifecycle? I'm looking for a skeleton Fragment that shows the lifecycle of the "myTracker" variable.

Thanks

user291701
  • 38,411
  • 72
  • 187
  • 285

2 Answers2

0

myTracker is instance of Tracker which you can get from EasyTracker.getTracker()

This is URL to concrete jar https://code.google.com/p/analytics-api-samples/downloads/list

ArturSkowronski
  • 1,722
  • 13
  • 17
  • Hi, I'm wondering where in a Fragment you would allocate "myTracker". Could you provide a skeleton example of a Fragment that uses a tracker? This is what's missing from the documentation. – user291701 May 21 '13 at 01:08
  • There is no method called getTracker() in EasyTracker class. – alicanbatur Oct 09 '13 at 10:50
0

Probably this might help you. Must say you should to search better. Anyway the main point is using of sendView() method.

Community
  • 1
  • 1
Stan
  • 6,511
  • 8
  • 55
  • 87