0

有使用Google Analytics跟踪 Android App 的给定解决方案。有没有办法通过 Android 应用程序跟踪网站?因此我们可以在我们的 Android 设备中查看报告,例如网站点击次数。这个问题的任何解决方案?

更新

public class AnalyticsTest {


      private static final String CLIENT_ID = "MY_CLIENT_ID";
    private static final String CLIENT_SECRET = "MY_CLIENT_SECRET";
    private static final String REDIRECT_URL = "urn:ietf:wg:oauth:2.0:oob";
    private static final String APPLICATION_NAME = "test";
    private static final String SCOPE = "https://www.googleapis.com/auth/analytics";
// TRIED AS WELL private static final String SCOPE = "https://www.google.com/analytics/feeds";
    private static final String TABLE_ID = "MY_TABLE_ID";

    public static void main() throws IOException {
            NetHttpTransport netHttpTransport = new NetHttpTransport();
            JacksonFactory jacksonFactory = new JacksonFactory();
            // Generate the URL to send the user to grant access.
            String authorizationUrl = new GoogleAuthorizationRequestUrl(CLIENT_ID, REDIRECT_URL, SCOPE).build();

            // Direct user to the authorization URI.
            System.out.println("Go to the following link in your browser:");
            System.out.println(authorizationUrl);

            // Get authorization code from user.
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("What is the authorization code?");
            String authorizationCode = null;
            authorizationCode = in.readLine();

            // Use the authorization code to get an access token and a refresh
            // token.
            AccessTokenResponse response = null;
            try {
                    response = new GoogleAccessTokenRequest.GoogleAuthorizationCodeGrant(netHttpTransport, jacksonFactory, CLIENT_ID, CLIENT_SECRET, authorizationCode, REDIRECT_URL).execute();
                    System.out.println("Responseeeeeeeeee "+response);
            } catch (IOException ioe) {
                    ioe.printStackTrace();
            }

            // Use the access and refresh tokens to get a new
            // GoogleAccessProtectedResource.
            GoogleAccessProtectedResource googleAccessProtectedResource = new GoogleAccessProtectedResource(response.accessToken, netHttpTransport, jacksonFactory, CLIENT_ID, CLIENT_SECRET, response.refreshToken);
            System.out.println("================== "+googleAccessProtectedResource.getClientId());




            Analytics analytics = Analytics
                            .builder(netHttpTransport, jacksonFactory)
                            .setHttpRequestInitializer(googleAccessProtectedResource)
                            .setApplicationName(APPLICATION_NAME).build();
            //System.out.println(analytics.management().accounts().list().execute());

            Get apiQuery = analytics.data().ga().get(TABLE_ID, // "ga:" + Profile
                            // Id.
                            "2011-09-01", // Start date.
                            "2011-12-23", // End date.
                            "ga:visits"); // Metrics.

            try {
                    GaData gaData = apiQuery.execute();
                    // Success. Do something cool!

            } catch (GoogleJsonResponseException e) {
                    // Catch API specific errors.
                    e.printStackTrace();

            } catch (IOException e) {
                    // Catch general parsing errors.
                    e.printStackTrace();
            }
    }
}

我正在使用上面的代码从谷歌分析网站获取分析报告。我从这里得到了所有 jar 文件但是无法找到Analytics的 jar,它向我显示错误。请告诉我我做错了什么?

谢谢

4

2 回答 2

1

您可以安装如下应用程序之一:

你是这个意思吗?

更新

要使用 Google Analytics API 推出您自己的应用程序,请从此处开始:http ://code.google.com/apis/analytics/docs/ 。

只需单击几下,您就可以到达Core Reporting API 概述。那可能有你正在寻找的东西。

于 2012-04-05T02:55:44.800 回答
1

有很多服务可供您选择:

1. Flurry:Flurry Analytics 提供了对消费者如何与您的移动应用程序进行实时交互的强大洞察力。超过 60,000 家公司选择 Flurry Analytics 用于 iOS、Android、Blackberry、Windows Phone、JavaME 和 HTML5 的 150,000 多个应用程序。

2.谷歌分析移动

3.混合面板

于 2012-04-04T12:56:40.683 回答