简体   繁体   中英

Track alert window on Google Analytics

How can I track floating view on android using Google Analytics . I am talking about view adds to window using WindowManager and Needed SYSTEM_ALERT_WINDOW permission.

Activity can tracked by EasyTracker using activityStart and activityStop these methods takes Activity as a parameter these methods are not exist in View

Any idea?

Create an xml file under res/values/ called analytics.xml

And organize this way:

<?xml version="1.0" encoding="utf-8" ?>

<resources>

<!--Replace placeholder ID with your tracking ID-->
<string name="ga_trackingId">UA-xxxxxxx-x</string>

<!--Enable automatic activity tracking-->
<bool name="ga_autoActivityTracking">true</bool>

<!--Enable automatic exception tracking-->
<bool name="ga_reportUncaughtExceptions">true</bool>

<string name="com.example.project.Class">Main Activity</string>
<string name="com.example.project.Class2">Activity 2</string>

</resources>

And in each Class/Activity, place this before you close last bracket:

//Tracker method starts..

@Override
  public void onStart() {
    super.onStart();
    // The rest of your onStart() code.


    EasyTracker.getInstance(this).activityStart(this);  // Add this method.
  }

  @Override
  public void onStop() {
    super.onStop();
    // The rest of your onStop() code.
    EasyTracker.getInstance(this).activityStop(this);  // Add this method.
  }

  //Tracker method ends..

Note: Imports for tacking will be automatically added. But make sure you have already settled with Google Service and libraries into your project before doing this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM