For Facebook and Insta ads there is a native ads feature known as CTWA(Click to WhatsApp Ads) through which if the campaign is executed then we get certain events pertaining to the user and the ads from which the user landed on the WhatsApp Bot based on which we can identify the source and other info.
But for Non-Meta platforms this is not available and the only way is to use a wa.me link(can be generated from Yellow’s Platform> Channels>WhatsApp>View More> Generate QR and Short Link) with a static text embedded to the first message based on which this could be tracked but it has a drawback that if the user edits the msg before sending it then it would not get logged based on the logic written on the bot to track the first message.