Use Twilio to track the effectiveness of your different marketing campaigns. Learn how call tracking helps organizations in these Twilio customer stories.
This project is configured to use a TwiML App, which allows us to easily set the voice URLs for all Twilio phone numbers we purchase in this app.
Create a new TwiML app at https://www.twilio.com/user/account/apps/add and use its
Sid as the
TWIML_APPLICATION_SID environment variable wherever you run this app.
You can learn more about TwiML apps here: https://www.twilio.com/help/faq/twilio-client/how-do-i-create-a-twiml-app
This project is built using the Django web framework. It runs on Python 2.7+ and Python 3.4+.
To run the app locally, first clone this repository and
cd into its directory. Then:
Create a new virtual environment:
Install the requirements:
pip install -r requirements.txt
Start a local PostgreSQL database and create a database called
CREATE DATABASE call_tracking;
createdb call_trackingfrom a terminal
Run the migrations with:
python manage.py migrate
Optionally create a superuser so you can access the Django admin:
python manage.py createsuperuser
.env_example file to
.env, and edit it to include your Twilio API credentials (found at https://www.twilio.com/user/account/voice)
source .env to apply the environment variables (or even better, use autoenv)
Start the development server
python manage.py runserver
To actually forward incoming calls, your development server will need to be publicly accessible. We recommend using ngrok to solve this problem.
Once you have started ngrok, update your TwiML app's voice URL setting to use your ngrok hostname, so it will look something like this:
You can run the tests locally through coverage:
$ coverage run manage.py test --settings=twilio_sample_project.settings.test
You can then view the results with
coverage report or build an HTML report with