Note: This tutorial makes use of this simple Twilio Click-to-Call recipe, which includes the three PHP files referenced below:

  1. Navigate to Phone Numbers and click “Buy a new number”, then search and choose a phone number you like (make sure it supports “Voice” capabilities, and not just SMS or Fax)
  2. Click on the Phone Number you’d like to manage and under “Configure > Voice & Fax” add a Webhook to the URL where your call-tracking.php file will be publicly available (ie. “example.com/call-tracking.php”).
  3. Copy & replace the following values in call-tracking.php and clickToCall.php :
    • Twilio Phone Number (the number you bought from Twilio)
    • Your Phone Number (the masked number you’d like to receive the call)
    • Your Twilio Account SID & Auth Token (from here)

    Be sure you have replaced the following lines:

    • line 28, clicktoCall.php
    • line 21 & 22, clicktoCall.php
    • line 3, call-tracking.php
    • line 43, call-tracking.php
  4. Upload call-tracking.php and clickToCall.php to any LAMP server (make sure PHP is installed) and copy the official Twilio PHP Helper library (download from Github / install via Composer) into the same directory under ./Twilio/
  5. Now you can paste the HTML snippet in clickToCall-form.html anywhere online that you’d like to add click-to-call functionality 🎉 — simply update line 33 with your URL if needed.
  6. Voilà! You can test your click-to-call solution by calling your own numbers, and you should see your call activity appear under “Voice > Overview” in the Twilio Dashboard. Make sure you have paid to upgrade from a “Trial” account before testing — otherwise you can only call “Verified Numbers” and the Twilio trial message will always play.

Add click-to-call functionality to your website in minutes, without any tedious coding: simply download the Twilio Click-to-Call recipe and follow the steps above (also available here)!

Get the latest releases & freebies first!Less than 1 email per month — only the good stuff. We hate spam too.