Sign in
Log inSign up

User count with React & Firebase

scanf6's photo
scanf6
·Feb 28, 2019

I'd like to add some statistics in the footer of my website:

Number of visits today Number of visits this month I'm using firebase realtime database with react. Now the approach i thought about was just to create a "componentWillMount()" lifecycle on the <App/> root component in which i will make a request to firebase and add a record with just the current date. So after i will just fetch that data and manipulate it in order to have the count for the users daily and monthly.

I'd like to know, is that the good move ? Are there some techniques, maybe in React or Firebase allowing to do this ? All i found was to implement Google Analytics (but i don't know how would that work, looks a lot to do just to make a simple count).