Display "x units sold in the last y hours!" With random x and y?

Hello all,

I know nothing about coding, trying to scrape together portions where I can. I’d like to display text on my page for example stating that 15 products have been sold in the last 24 hours. I know how to get the text up and the location for it, but I’d like for the numbers to be random. How can I generate random numbers, and display that? Here is the code snippet I have currently:

38 sold in last 24 hours.

There’s a bit of extra fluff…copied this code from elsewhere. Essentially I want the 38 and 24 to be random.

Thanks!

Hi @BrandonSLLC

I can definitely understand the value of creating urgency on your store to help drive sales. I wanted to make sure you were aware that creating an urgency promoter that is not using accurate information and instead using randomized numbers, fake countdowns, etc, are considered a deceptive and misleading practice and that it goes against Shopify’s Acceptable Use Policy.

You can read more about this in our Help Center here: Consumer protection laws.

In regards to coding a random number using Liquid, that can be done using some creative workarounds. Here is a great suggestion that the merchant confirmed worked for them: Is there any way to generate random number with liquid shopify?.