Skip to main content

Get dynamic numbers on your website

Dynamic number insertion allows for web pages to display telephone numbers that are unique to each visitor. This enables you to track visitors on your website, where they come from and what is driving your phone calls. This is achieved by Mediahawk providing a pool of numbers which then dynamically change when a user enters a page on your website.

Before you begin this guide, please ensure you have followed the Authenticate guide and have a valid token.

You can download a full working code example for this guide here:

CURL, PHP, Node.js, Python, C#

Add a dynamic URL

Each website that you want to track will have to have it's own dynamic URL. This allows us to track visitors to the website and update the phone numbers on the website to be trackable. To add a new dynamic URL, you will also have to add a pool as every URL must contain a pool. A pool is a set of tracking numbers. You may use one pool for client services and one pool for sales if you want to track calls to them separately or they have different destination numbers.

apiKey="<API_KEY>"
url="<WEBSITE_URL>"
poolName="<POOL_NAME>"
prefix="<NUMBER_PREFIX>"

curl -L -X POST "https://www.reports.mediahawk.co.uk/rest/v2_0/urls?api_key=${apiKey}" \
--header "Content-Type: application/json" \
--data '{ "url": "'$url'", "google_bot_filter": true, "subdomain_tracking": false, "pool": { "name": "'$poolName'", "prefix": "'$prefix'", "format": "08000000000", "numbers_to_replace": [] } }'
tip

Each pool has a routing that tells us where to send calls. If you have different routings for different phone numbers, you will require multiple pools.

Add additional pools

info

This step is optional.

If you have any other phone numbers on the website you'd like to track, add those pools now.

apiKey="<API_KEY>"
# The unique tracking reference of your dynamic URL
vaCode="<VA_CODE>"
prefix="<NUMBER_PREFIX>"
poolName="<POOL_NAME>"

curl -L -X POST "https://www.reports.mediahawk.co.uk/rest/v2_0/urls/${vaCode}/pools?api_key=${apiKey}" \
--header "Content-Type: application/json" \
--data '{ "name": "'$poolName'", "prefix": "'$prefix'", "format": "08000000000", "numbers_to_replace": [] }'

Get the instructions

Once you have added your dynamic URL, you need to get the instructions that tell you how to set it up on the website.

apiKey="<API_KEY>"
# The unique tracking reference of your dynamic URL
vaCode="<VA_CODE>"

curl -L -X GET "https://www.reports.mediahawk.co.uk/rest/v2_0/urls/${vaCode}/instructions?api_key=${apiKey}"

Update your website

The final step is to add the code to the website. This can be done easily through Google Tag Manager or directly in the HTML. The process is explained on our support site.