Search code examples
phpanalyticstrackinguser-tracking

How to track users on my website?


so I have a shopify website. And shopify sometimes give me a visitor log kind of like this:

"A user from has visited your website, First page visited: homepage (22 seconds) About us (1 minute) Product page (2 minutes)"

I was wondering how I would go about creating something similar to this in php/js.

Thanks in advance!


Solution

  • You can instead use Google Analytics, it has in depth analytics on visitors. Its just about embedding JS code in your page and you're good to go. If you build your own code in any language, I'm pretty sure you will end up writing tonnes of codes.

    To answer your question,

    1.Create a web socket connection from your page to backend.

    2.Pass event codes like clicks, refresh, session ids etc on user actions. Your JS can fire them up with an active web socket connection. It is pretty much light weight.

    To store this information, I would suggest to use NoSql.

    Hope this helps!