Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track java servlet request using Google Analytics

I have a common link http://www.mydomain.com/clickServlet on various third party client pages with different parameter values (http://www.mydomain.com/clickServlet?ID=123&A=123&B=123). The link is of a java servlet. Based on the parameter values the request is redirected to an external domain.

I want to track this at java servlet level. Since i do not have access to client pages (pages where my link resides) and redirected domains, i have to setup tracking in java servlet which should record all details like referer, ip, location, user-agent etc. all the stuff which GA records. I need a solution like wherein I pass the java HttpServletRequest object along with GA account details and GA would record all the details from the request object.

Is this possible in Google Analytics API?

like image 745
Dilip Jain Avatar asked Jun 07 '26 07:06

Dilip Jain


2 Answers

Google released an official API to send data to Google Analytics now. This is the Google Analytics Measurement Protocol. This is probably the safest solution because it is an "official" and documented API.

like image 146
Dilip Jain Avatar answered Jun 08 '26 20:06

Dilip Jain


You can give a try JGoogleAnalytics library a try. It can track usage information on Java applications through Google analytics. It can be used for gathering usage statistics on utilities, plugins(Eclipse, IntelliJ, Netbeans etc.), client-side, server-side, middleware, desktop or any Java based applications. Hence, allowing us to perform usage & trend analysis on the application of interest.

like image 31
Łukasz Rżanek Avatar answered Jun 08 '26 21:06

Łukasz Rżanek