简体   繁体   English

从Java桌面应用程序向Google Analytics发送统计信息

[英]Sending statistics to Google Analytics from java desktop application

I have a JavaFX desktop application which allows users to login, load and save data on remote host using HttpRequest GET and POST methods (for instance, by pressing buttons Login, Load, Save). 我有一个JavaFX桌面应用程序,允许用户使用HttpRequest GET和POST方法登录,加载和保存远程主机上的数据(例如,通过按下按钮登录,加载,保存)。

I'd like to monitor user's interaction with that application using Google Analytics. 我想使用Google Analytics监控用户与该应用的互动情况。 Are there any usage examples of how this can be done? 是否有任何使用示例可以做到这一点? I guess, I need to add listeners to those buttons and call GA API? 我想,我需要为这些按钮添加监听器并调用GA API?

Maybe some examples of how to connect to google and what parameters need to be passed there? 也许一些如何连接到谷歌的例子以及需要传递哪些参数?

Thanks in advance! 提前致谢!

I found the solution using the following library It has a GA tracker constuctor where you can put your application name and tracking code: 我使用以下库找到了解决方案它有一个GA跟踪器构造器,您可以在其中放置应用程序名称和跟踪代码:

 private static final JGoogleAnalyticsTracker MONITOR = new JGoogleAnalyticsTracker("My app", "UA-10086test-1");

And then use it's method "trackAsynchronously()" whenever you want with required description: 然后根据需要使用它的方法“trackAsynchronously()”:

Main.getMonitor().trackAsynchronously(new FocusPoint("Submit login"));

Compiled it locally and added to my pom: 在本地编译并添加到我的pom:

    <dependency>
        <groupId>jgoogleanalytics</groupId>
        <artifactId>jgoogleanalytics</artifactId>
        <version>0.5</version>
    </dependency>

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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