0

I am using drupal 7, I have seen there are already statistic modules but can't find any for my situation

On my website I am trying to track certain on page activities which site admins can see in a table.

Example of activities are if users engage with certain elements on a page, if certain images load before user leaves, and browser information. Alot of information is only available through JS or Jquery not PHP.

On my site I can build a client side log, so when I go to console I can see the statistics I am looking for, but what is the best way to save this log/statistics to by drupal database.

I was thinking of building a content type called 'page log' with different fields relating to page info I need, which would be loaded on every page and filled/submitted via javascript. But think this would be too resource intensive.

To summarise, I have been building a function in javascript which collects on page activities which currently I can view in my browser console. I am looking for a way to save the log for each page to my drupal site in a way which can be recalled easily. Probably through views.

How can I save this log? Thanks for any help

0

Since, you've built everything in js, next thing to do is send the data from the client. You could do that with an endpoint in a custom module and sending everything you want there with ajax. From there it depends how often you anticipate db writes from these data and you can assess the next step to take. You could:

  • Create a content type and programmatically save data to it.
  • Create a custom db table with only the fields you want and implement some db logic to save data.
  • Use mongoDB and setup a document table to store these data. This is the best option performance wise. You would need to setup the mongoDB module for it.
  • Thanks for replying. I would have a db write for each session at least, and theres what I'd consider a lot of data being sent. I think using a content type provides more flexibility. I am concerned about how I would programatically save the content type. – Tasha Jordan Apr 4 at 13:16
  • After you make your content type saving new nodes for it isn't hard at all. Something like this will help you get started: drupal.stackexchange.com/questions/230097/… – seroton Apr 4 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.