This is an interesting question. You can find special software on the Internet for this or just use an extension like this https://www.mageworx.com/magento-2-c...er-number.html . This extension is suitable for sites created on the basis of Magento 2, if your site cann't work with this extension, then you can search the Internet for another similar one. I advise you to choose a reliable extension developer with a good reputation. This will allow you to avoid many problems in the future.