I have created a Gatsby blog for my friend, which means it is serverless and does not use a database. This works quite well for a blog which will only need builds every time I make changes or he adds a blog post - however it wouldn't work too well for tracking unique user visits as it would have to do too many builds if many people visited within a short time span.
Is there a way I can track unique user visits without a database involved?
Like it has been said, you need a third-party tool (like Google Analytics) since any workaround done in the front-end part will be related to the client/browser-side, then you'll lose the tracking if a user changes the device for example.
You can easily install Analytics with some of the available plugins (like
gatsby-plugin-google-gtag). This is recommended since under the hood usesgtag.jsinstead ofanalytics.js, which is what Google recommends due the last API changes.To use is just install it by:
And add your configurations:
You can ignore the options you don't need.