SIGN UP

Call Tracking

Call Tracking


Call tracking lets you analyze the effectiveness of marketing channels and optimize your campaigns accordingly. It's easy to implement call tracking using VoxImplant and get all information about calls going via the system, including dialed number, time of day it was dialed, call duration, number where it was forwarded, call record and much more. You can get phone numbers either from VoxImplant directly, or connect your own phone numbers using SIP trunk.

Let's create our VoxImplat call tracking application:

  • Login into the VoxImplant control panel.
  • Create new application in the Applications section and call it calltracking.
  • Create new scenario in the Scenarios section with the following code:
    let outbound_call;
    let dialed_number;
    let agent_number;
    let record_url;
    let call_date;
    let failure_code;
    let failure_reason;
    // let's assume we will receive the number for forwarding
    // there, don't forget to change this to something real
    let wsURL = 'http://demos.zingaya.com/calltracking/call.php';
    let call_length = 0;
    let connected = false;
    
    // Inbound call arrived
    VoxEngine.addEventListener(AppEvents.CallAlerting, (e) => {
      call_date = new Date().toUTCString();
      dialed_number = e.destination;
      wsURL += `?dialed_number=${encodeURIComponent(dialed_number)}`;
      // make http request to get
      // the corresponding number(s) for call forwarding
      Net.httpRequest(wsURL, function (res) {
        if (res.code === 200) {
          // received phone number(s) for forwarding
          agent_number = res.text;
          outbound_call = VoxEngine.callPSTN(agent_number, dialed_number);
          VoxEngine.easyProcess(e.call, outbound_call, handleCallsConnected);
          outbound_call.removeEventListener(CallEvents.Disconnected);
          outbound_call.addEventListener(CallEvents.Disconnected, handleCallDisconnected);
          outbound_call.removeEventListener(CallEvents.Failed);
          outbound_call.addEventListener(CallEvents.Failed, handleCallFailed);
        } else {
          // webservice unavailable - reject the call
          e.call.reject();
        }
      });
    });
    
    VoxEngine.addEventListener(AppEvents.Terminating, (e) => {
      if (connected) {
        Logger.write(`Dialed number: ${dialed_number}  Agent number: ${agent_number}`+
          ` Date: ${call_date} Length: ${call_length}`+
          ` Record URL: ${record_url}`);
        // notify webservice about successful call, use Net.httpRequest
      } else {
        Logger.write(`Call failed. Code: ${failure_code} Reason: ${failure_reason}`);
        // notify webservice about failed call, use Net.httpRequest
      }
    });
    
    function handleCallFailed(e) {
      failure_code = e.code;
      failure_reason = e.reason;
      VoxEngine.terminate();
    }
    
    function handleCallDisconnected(e) {
      call_length = e.duration;
      VoxEngine.terminate();
    }
    
    function handleCallsConncted(call1, call2) {
      connected = true;
      outbound_call.addEventListener(CallEvents.RecordStarted, (e) => {
        record_url = e.url;
      });
      outbound_call.record(); // start call recording
    }
    
  • Edit your application at control panel and add app rule to forward inbound calls to the created scenario. You can call it InboundTracking, no need to change default Pattern, don't forget to drag'n'drop the scenario to Assigned list before pressing Add button.
  • Buy phone number(s) in Phone numbers section of the control panel and then assigned it to calltracking app.
  • If you didn't forget to change wsURL in the scenario to something that returns phone number for call forwarding then you can make a call to the number you've bought and see the tracking in action.

It's a very simple example of the call tracking app. You can modify it to let the scenario forward the call to a few numbers simultaneously or try to call them one-by-one till somebody answers. If the call wasn't forwarded correctly you can always make a callback to the customer (you don't want to loose your customers, do you?).

Tags:call trackinganalyticsphone numbers
B6A24216-9891-45D1-9D1D-E7359CEB8282 Created with sketchtool.

Comments(0)

Add your comment

To leave a comment, first confirm that you are not a robot. It's free

Recommend

Get your free developer account or talk with our sales team to learn more about Voximplant solutions
SIGN UP
Contact sales

Please complete this field.

Please complete this field.

Please complete this field.

Choose the solution

Please complete this field.

Please complete this field.