Reputation: 23
I have an application which is built in Java SE to store user data after they register and log in to their accounts.
I want to track the users using Google Analytics which we use to track websites visitors.
If this is not possible with GA, how could I track users using the application? I'm interested in gathering their IP address, country, and other info.
Upvotes: 2
Views: 1745
Reputation: 1778
I use this java library that allows you to send page and events to your google analytic account:
https://code.google.com/p/jgoogleanalyticstracker/
Here's how to use JGoogleAnalyticsTracker:
JGoogleAnalyticsTracker.setProxy(System.getenv("http_proxy"));
AnalyticsConfigData config = new AnalyticsConfigData("XX-XXXXXXX-X");
JGoogleAnalyticsTracker tracker = new JGoogleAnalyticsTracker(config, GoogleAnalyticsVersion.V_4_7_2);
tracker.trackEvent("MyEvent", "MyAction", "Here is a msg");
You can also use the one below which is newer and implements the latest google analytics API but I don't like it because of its dependancies on jlogger library:
https://github.com/brsanthu/google-analytics-java
Upvotes: 2