Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello guys!
Today I was trying to find a solution to create a dynamic text whatsapp link. I mean a whatsapp link which automatically writes something like: "Hello I'm interested in {{ product name }}".
Is there a way to make it work? Maybe with JS?
Thanks in advance!
Adriano
Yes, it is possible to create a dynamic WhatsApp link that includes information such as the product name using JavaScript. This can be done by using a JavaScript function to construct the link with the desired information and then adding it to the page as a clickable link.
Here is an example of how this could be implemented:
<script>
function createWhatsAppLink(productName) {
// Construct the WhatsApp link with the product name as the message
var whatsAppLink = "" + productName;
// Create a clickable link with the WhatsApp link as the href attribute
var link = document.createElement("a");
link.href = whatsAppLink;
link.innerHTML = "Click here to send a message on WhatsApp";
// Add the link to the page
document.body.appendChild(link);
}
</script>
To use this function, you would need to call it and pass the product name as an argument. For example:
<script> // Call the createWhatsAppLink function and pass the product name as an argument createWhatsAppLink("{{ product.name }}"); </script>
Otherwise you create a WhatsApp Business Account - There is an Option for Pre-Selected Answers/Questions when the customer clicks the link
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025