1

How can I track a user action on my website?

What I want to do is track when the user viewed product, and then display related products to the user.

Would this be different between ga.js and analytics.js from Google? Which method of Google Analytics should I use? Page tracking?

1

Use Analytics events. More docs here: Event Tracking - Web Tracking (analytics.js)

0

Google Analytics is not sufficient for your use case. Your system doesn't have real time access to the data collected by Google Analytics for a particular user. Because of this, you can't use Google analytics data to change what is later displayed on the site to the user.

You may want to use Google Analytics to track which products get viewed on your website anyway. It is useful to see stats on your products to make decisions about which products to feature. If each product has its own page, then page tracking is appropriate. If products get loaded via AJAX then you will need to use events.

To display related products to users, you will also need to track a list of viewed products where the server can read it. User cookies or a server side session object would be the places that this information would normally be stored. Once you have a list of recently viewed products, your server can use that to generate a list of related products to show the user.

If you are just implementing Google Analytics for the first time, you should use Universal Analytics (analytics.js). That is the newer version with more features. Google will eventually be converting all sites over to it.

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.