Want to implement “Text us” or “Text me” link or button on your website for mobile users?
Here is the script that you can use to make it work for both Android and iPhone devices.
Step 1 – Add Anchor Link
First, create an anchor or link. Add it to somewhere on the page i.e. inside the <body></body> tag. Since, the text me or test us link will work for mobile users only, add required CSS styling to hide it for desktop users.
<a href="sms:+10000000000" id="txtMsg">Text Us</a>
Add the following piece of script/code right before closing of </body> tag.
Once you’re done adding the code. On each page load, the href value will be replaced dynamically with the one we have mentioned in the step 2.
Based upon the visitors, device… the appropriate sms formats will be applied.
Don’t forget to update your phone number +10000000000 with your own phone number and the text message “Hi, I have a question regarding your service:”.
Click on the below link from your mobile to test this script.Text Us