How can I show a number of people 'viewing' a product on my site?

I recently tried to copy the code from the top answer on this post "https://community.shopify.com/topic/1043345" but it seems to be either outdated or doesn’t work with Dawn or Shrine theme? I am trying to stay away from apps as much as I can so I am looking for custom code alternatives. I would like to have the live counter, even just random numbers 3, 10, 23, etc.

Any answers would be greatly appreciated.

Hi Timecom,

Showing a random number of people viewing a product would be misleading to customers so I wouldn’t recommend that strategy. The Trafficly ‑ Visitors Counter app is free, have you tested this out?

People still look at this thread 1 year on? Thanks lol.

@Timecom @Liam gave the legimate answer.
You can get your store deplatformed faking numbers like this.
A keyword for business risk is : deceptive

Yes people will look when they search for hard to solve problems like this because it needs a backend app to do properly and above board without possible legal issues.

The post you’ve marked is not an actual solution, it’s FAKE if not outright fraud or illegal in some regions under pro consumer laws against misrepresentation and anti-consumer dark patterns.
And then it has the gall to charge for code that just changes a FAKE number to present to customers when merchants could probably just ask the built in section/block generator to make this for free.

Violating shopify’s TOS:

Claims about product popularity and availability should be clear and accurate. Potentially deceptive or misleading marketing include the following examples:

Examples are NON-EXHAUSTIVE, meaning just because your specific random number dispaly is not in the examples that doesn’t mean the rules don’t apply to you or other merchants faking numbers.

Walk very carefully when doing FOMO patterns like this as it’s incredibly easy to be lazy and take the scummy route of fake numbers and not use REAL data.

Probably just need to get this thread nuked at this point.