So I have these tiles (emilsjoberg.se/w) on my website and I’d like there to be a ‘view’ counter for each person clicking on it.
I know a lot of people have put this on a wish list, but I’m hoping you could direct me to somewhere I can find code or something to help me achieve this.
Thank you so much and it might definitely help. Problem is that we need to make webflow remember the click and display it for every user. Imagine it as a youtube views counter.
So I want it to look something like this and count each person visiting.
If you are using Google analytics you can use their API.
The Reporting API V4 is what you would need as it allows you to pull from the analytics on your site. The “Realtime API V3” is for real time data like live visitors and such. It’s in limited beta so you have to apply and get whitelisted to use it. However, I’d wager this is probably overkill for what you are trying to accomplish. (Or just more work than it’s probably worth)
The main issue here is that Webflow doesn’t allow us to access the database. So you basically two options
Option 1: Find a way to store the updated page count outside of Webflow
To start any third party solution can fill this role. The first solution I gave earlier, the Google Analytics API, would all be hosted by Google which is why the page count can be retained unlike the Codepen linked above.
Perhaps there’s some business offering this as a paid solution I’m not sure. I haven’t seen anything like that though.
Another way you could do this is by hosting a spreadsheet in Dropbox or Google Drive. For example you can use Google Sheets to act as your “database.” Basically when someone visits your page you would have a Javascript command that updates the Google Sheet, and then another Javascript command that pulls the number of visitors from the spreadsheet.
The webflow API allows us to create new collection items and update them as well. So theroetically it would be possible for you to have a field in your collection titled "Number of Visitors" or something to that effect. Then utilizing the API I suppose you could push an update to that collections "Number of Visitors" field whenever someone visits the page.
I haven’t really played with the Webflow API. So this is just me speculating based on my quick read through of their documentation.
There is already a view counter in the forum if you look on links. The number is how many people clicked on it. So we know it’s definitely possible, question is how they did it.
This is going to take some time learning, hopefully it will work out.
Oh, no worries on the (post withdrawn). I had replied and added some code to this post to see if it would work as expected, then withdraw my reply after testing.
That’s all.
Glad it helps.
There are a couple others that are pretty much exactly like the previously mentioned counter:
Just to note that I’ve looked at this thread about 5 times over the last year to check to see if there is any update here. Would be brilliant to have a view counter on blog posts to see which are the most popular.
Hey, reviving this thread after a few years because I too have this problem now, did any of you guys manage to figure this one out? Did implementing CountAPI help?
Actually, specifically, I’m wanting to have a view counter on individual CMS items, no matter which page they’re referenced on, not just the CMS page. For example I’m making a music player as a test project, and want to know if its possible to implement a view counter for plays on each track. Each track will be its own CMS item, and I’ll display multiple tracks per page. Similar to soundcloud.