Shorten a long URL and track clicks in SMS
7 min
you can use exotel's sms api to shorten a long url in sms and you can track customer's click data as well shortening a long url will also reduce the number of characters in sms and allow you to stick to the 160 characters limit for sms follow steps below to set it up 1\ get in touch with your account manager or drop an email to " hello\@exotel com " to enable url shortening services for your account 2\ while making the api request to send sms, make below changes to your sms request set parameter "shortenurl" 'true' if you want to shorten a url, to provide flexibility, we allow you to set it to 'false' as well don't want to shorten any particular sms set parameter "shortenurlparams\[customdomain] " with the custom domain you want the short url to start with if custom domain is not present or empty, we will use the default domain(exo tl), if custom domain is given in the request it will be used to form the short url note clients will have to route the traffic on their custom domain to exo tl domain, this is a change on your domain management system set parameter "shortenurlparams\[tracking] " 'true' if you want to track data when a customer clicks on the url this feature is currently available to select customers in parameter "shortenurlparams\[clicktrackingcallbackurl]” enter a valid url to receive click tracking data you can also use sample requests available on our developer portal to use the feature and use the sample collection from postman 3 below would be the api response , sms will be delivered with a short url eg https //exo tl/vhdpzv the short url has a validity of 1 month 4\ whenever someone clicks on the shortened url, the following data would appear in the url provided in "shortenurlparams\[clicktrackingcallbackurl] sid the sid (unique id) of the shortened url short url the complete shortened url short code key of the shortened url long url original url which is shortened tracking whether the url is being tracked or not custom field custom field passed in sms api request expires at date time in iso format when link will expire created time date time in iso format when url is created last viewed date time in iso format when link was visited last total clicks count of total views of short url account sid exotel’s unique account sid country code country code of the customer who received the sms date created date time in iso format when link was created sms sid the sid (unique id) of the sms, this sid can be used to track the sms to contact number of the customer who clicked on the url city city where the shorten url is clicked country country code where shorten url is clicked ip ip address where shorten url is clicked postal code postal code where shorten url is clicked region region where shorten url is clicked accuracy radius aproximate accuracy radius where shorten url is clicked os version os version of the customer who clicked the shorten url os name os name of the customer who clicked the shorten url device name device name of the customer who clicked the shorten url platform type platform where shorten url is clicked using the standalone compactix api you can use exotel's compactix api to shorten a long url and track customers' click data as well shortening a long url will also reduce the number of characters and create your own short links in follow the steps below to set it up use default keys and tokens available in your account to use this api get in touch with your account manager or drop an email to " hello\@exotel com mailto\ hello\@exotel com " if you face any issues request parameters you can use the api with the following request parameters parameter description long url the long url you want to shorten expire in the duration (seconds) after which the short url becomes invalid minimum is 60 seconds and the default is 31 days max value is 365 days tracking whether to track the urls present in the sms can be "true" or "false" "shortenurl" needs to be "true" for tracking to work callback url the url where you want to receive the tracking details once someone clicks on the shortened url, exotel will do a post callback to your endpoint if the url is set as a parameter in the api custom field a custom field relevant to your use case while sending a long url e g order id, payment id, login attempt etc any content / json body upto 1024 chars custom domain the custom domain you can specify whether you want the short url to start with the default domain (exo tl) or you want to provide a custom domain of your own choice note clients will have to route the traffic on their custom domain to exo tl http //exo tl/ domain, this is a change on your domain management system click tracking callback schema whenever someone clicks on the shortened url, the following data would appear in the url provided in callback url field description sid the sid (unique id) of the shortened url short url the complete shortened url short code key of the shortened url long url original url which is shortened tracking whether the short url is being tracked or not custom field custom field passed in api request expires at date time in iso format when link will expire created time date time in iso format when url is created last viewed date time in iso format when link was visited last total clicks count of total views of short url account sid exotel's unique account sid date created date time in iso format when link was created city city where the shorten url is clicked country country code where shorten url is clicked ip ip address where shorten url is clicked postal code postal code where shorten url is clicked region region where shorten url is clicked accuracy radius approximate accuracy radius where shorten url is clicked os version os version of the customer who clicked the shorten url os name os name of the customer who clicked the shorten url device name the device name of the customer who clicked the shorten url platform type platform where shorten url is clicked below is an example of a callback with the parameters example of a callback with the parameters on successful execution of the api, you will be given a short url in response that can be used by you read more about the api response on exotel developer portal https //developer exotel com/api/url shortening if you have any questions or concerns, please connect with us using the chat widget on your exotel dashboard or whatsapp us on 08088919888