Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tracking Clicks in a Grails App

 
Juan Marcos
Greenhorn
Posts: 12
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a min ProgramController which dictates the overall application, including direction to each URL within the application itself (i.e., def homePage, def movieNight, etc.).

What I am trying to do is put an incrementing variable within each method listed above to track clicks, then update and persist that variable to the database which my ClickTracker domain
class has generated. I have two variables within my ClickTracker domain.

I'm working with a MySQL Database.
What I want to do is create ONE row per URL and update only the "visits" variable in the database each time it's navigation button is clicked without having to create and
persist a new URL instance within the database, i.e.;
url_name: HomePage Visits: 150
URL Name: Fireside Chat Visits: 45

Any recommendations?

Thanks.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My recommendation would be to not use a home grown solution and go with something like google analytics. It's pretty simple to add some junk to your links that then propagate to GA every time one of them is clicked.
 
Juan Marcos
Greenhorn
Posts: 12
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the input Gregg. I'm actually interning at a company right now, and those were the instructions that my boss gave me. I know that Grails has some really useful plugins as well for what I'm trying to do.

It took me a number of hours to come up with a solution

But what I ended up doing was creating a general domain class to track the event, then I increment each event method that calls the specific URL I need to track within the main ProgramController, thus persisting and updating my MySQL database.

I'm not quite sure if that's what he wants, but I'm sure I'll find out once he comes back from the trade show.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic