简体   繁体   中英

Record unique views on the web with Firebase Realtime Database

I'm building a React web app, where users can create 'content'. The content is displayed when a certain URL is visited, eg: https://myapp.com/username/contentid

The user doesn't have to be signed in to view the content.

My question is, how do I track unique views with Realtime firebase?

I don't necessarily need a code implementation, rather an idea/approach. Thanks!

First, you would need to enable your database to allow for writing capabilities from anonymous users. From there, write to the database when the site is first opened. You could store this information in a variety of different ways, I would recommend posting a timestamp and seeing total unique views by counting the total amount of timestamps uploaded. It may also be important to store locally, via Cookies, if the user has been to the site already. If they have, don't write.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM