Push Application statistics products (number of) Android integration practice

Source: Internet
Author: User

Recently, the product department has put forward to US statistics app data demand, we tested several products after selected "number", it is a push its application statistics products, overall data fast quasi ruthless, experience is also good. This experience will introduce you to the detailed steps of integration.

First, login account and create the application
    1. Visit the Push Developer Center and click Register Now (if you already have an account you can go directly to step 3):

    1. Fill in and register your account according to your personal circumstances:

    1. After registering, you can log in, select the number of the menu bar on the left side of the main screen and apply statistics:

4. Enter the number • After applying the statistics panel, select "New app" in the upper right corner to add a new app:

5. Fill in the application information, tick Android, click Submit:

6. Once submitted, the page will automatically return to the app list and we'll be able to see the app you just added. Click Apply configuration:

7. In the application configuration interface you can see the AppID, we can copy and save it, it will be used in the subsequent integration process:

Second, the number of configuration SDK

The number of Android SDK offers two integration methods, namely MAVEN integration and AAR Pack manual integration (I recommend using MAVEN integration for easier and easier).

Third, Maven integration method

1. Add Maven Library Address

In the top-level Build.gradle file named after the project name, add a push Maven library address as follows:

maven{
URL ' http://mvn.gt.igexin.com/nexus/content/repositories/releases '
}

2. Configure dependencies

In the App/build.gradle file, refer to the number of SDK dependency libraries, as shown in:

dependencies{
Compile ' com.getui:gssdk:2.2.3.0 '
}

Four, AAR package integration method

Go to the official website to download the SDK documentation

Copy the Gssdkxxx.aar and Gtcxxx.aar in the resource file into the Libs file under the app module, open App/build.gradle, and add a reference to the corresponding package in dependencies:

dependencies {
Implementation files (' Libs/gtc-2.0.0.aar ')
Implementation files (' Libs/gssdk-2.2.2.0.aar ')
}

GTC is a common code base for push platforms, and if you've already plugged in other products that include GTC, you don't need to introduce them again.

Five, SDK configuration

This step requires configuration confusion. First, you need to include the following configuration in the obfuscation file:
-dontwarn Com.getui.
-keep class Com.getui.
{*;}

Then configure the number of application parameters:

In the App/build.gradle file, under Android.defaultconfig add manifestplaceholders, configure the number of parameters related to the application, as shown in:

Manifestplaceholders = [
Gs_appid: "app_id",
Gt_install_channel: "App_channel"
]

APP_ID for the value obtained from the official website in step 1, App_channel is the channel that will be published.
App_channel can also be set by Setinstallchannel methods in the Gsconfig class. It is important to note that if you use this method, you need to configure it before the SDK is initialized, otherwise it will not take effect.

With this step done, the SDK integration work is done.

VI. SDK Initialization

The initialization of the number SDK is very simple, just add the following code in the application OnCreate mode:

Gsmanager.getinstance (). Init (context context);

After initialization, the SDK product function will be used normally. New, daily live, retention rate, per capita visit duration, number of views on each page ... App data statistics related to the various indicators, can be completed by the number of SDK automatic statistics.

Vii. Some of the custom features

Application time-Length statistics:

Application time-length statistics are mainly used to count the number of app launches and the actual active duration, the integration of the number of SDKs does not require the developer to call the additional interface. One of the following two scenarios where the Android platform is a complete start-up refers to:
(1) from the start app to the close app.
(2) from the launch app to the app back to the background, and run in the background longer than the default value of 30s. This default value supports modification:

void Gsconfig.setsessiontimoutmillis (long time);

Note: The operation of the Gsconfig configuration class needs to be completed before the SDK is initialized.

1. Custom Event Function:

Custom events can count the time and number of times a user has customized a site, such as ad clicks, text messages, and so on. Typically event_id is used to represent a statistic of a behavior or function (such as how many times the "Send" button is triggered), whereas the parameter properties are used to identify the specific object being counted (such as a button that features "Download"). With event_id and properties, we can uniquely identify an event.
There are two main categories of custom events:
(1) Count: Counts the number of times a specified behavior has been triggered.
(2) Time-length statistics: The time that the specified behavior is consumed, in seconds. The Eventbegin and Eventend interfaces need to be used in pairs to take effect.
Each of these events supports the use of the properties parameter type.
Note: event_id needs to be configured on the number of sites before it can participate in normal data statistics. EVENT_ID cannot contain spaces or escape characters, as follows:

(1) Click on the Side menu bar Event list.

(2) Click the Add Event button.

3. Enter the corresponding Event ID and event name, respectively, based on the event type.

There are two types of custom events for the current number:

1. Number of statistics events

At the beginning of the event execution, the Count method is called, and the SDK counts the number of times the event was clicked based on the event ID.

void Gsmanager.getinstance (). OnEvent (String eventId, properties properties)

Parameters:
EventId: Custom Event ID to identify Unique Events
Properties:key-value, custom attributes, for scaling statistical requirements
Both key and value are string types

Using code:

1. Event Duration Statistics

The corresponding method is called at the beginning and end of the event to obtain and upload the time of the event.

void Gsmanager.getinstance (). Onbeginevent (String eventId, properties properties)

void Gsmanager.getinstance (). Onendevent (String eventId, properties properties)

Parameters:
EventId: Custom Event ID to identify Unique Events
Properties:key-value, custom attributes, for extending statistical requirements, both key and value are string types
Using code:

1. Data upload Strategy

Developers can set different data escalation policies according to their own application requirements, thus effectively controlling user traffic overhead.

(1) Number of currently supported escalation policies include the following 5 types:

void Gsconfig.setuploadstrategytype (Gsconfig.geshu_strategy_real_time);

The default rule is to upload the data in real-time, with WiFi on, and then report it every 1 hours without connecting to WiFi. Developers can also manually turn off the real-time uploading of data in the WiFi environment.

void Gsconfig.setenablesmartreporting (Boolean isenable);

(2) Data upload related Settings interface

1) (only valid when the sending policy is geshu_strategy_period) set the interval (default is 60, in minutes, or 1 hours)

void gsconfig.setuploadperiodminutes (int minutes);

2) (only valid when sending policy is Geshu_strategy_batch) set the maximum number of bulk send messages (default is 32)

void Gsconfig.setmaxbatchreportcount (int maxCount);

Note: The Gsconfig configuration class needs to be completed before the SDK is initialized.

The above content is I integrated a push application statistics products (number) Experience Summary, I hope you have help! If you encounter problems in the integration process, you can find their technical support at the bottom of the push website, or leave a message in the comment area, we solve together, progress together.

Push Application statistics products (number of) Android integration practice

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.