📜 ⬆️ ⬇️

We do call tracking

In the modern world, companies use a large number of channels to attract customers: contextual advertising, banner advertising, advertising on radio or TV, outdoor advertising, and so on. Each of these channels may still contain placement parameters, for example, keywords or sites. Advertising is costly and a business has a clear desire to study the effectiveness of various channels and sites. In the case of online sales, everything is more or less simple and worked out, there are special tags and cookies that cling to the client’s browser and, when he makes a purchase, Google / Yandex / any other system gives you information that the client came from a certain channel via some particular keywords. But not all companies sell goods or services online, many still do it by phone, every business has its own specifics and the phone as a sales channel has not lost its relevance. In order to analyze the effectiveness of marketing channels in the case of telephone sales, call tracking is used, then we will consider the types of call tracking and describe how it can be implemented.

There are several types of call tracking - static and dynamic. In the case of static call tracking, each advertising channel is allocated its own number and assigned to it, then all calls through numbers are recorded and the analysis of statistical information shows which of the channels is most effective. This method works well if you need to track a limited number of channels. In the modern world, advertisers want to track not only the channels, but also the effectiveness of certain keywords and catch individual customers, which ultimately leads to the need for a large number of numbers.

In this case, they begin to use dynamic call tracking: with dynamic call tracking, there is a certain pool of phone numbers that is used for all channels, but a bunch of numbers with the site visitor occurs on the fly and a limited amount of time is valid if during this time If the customer calls the number, the system will track it. There is a ratio between the number of visits to the site and the number of numbers that are necessary for tracking visitors to the site from different channels, so call tracking services usually tie the price of their services to the attendance of the resource.
')


Well, everything, with the theory finished, you can proceed to practice. We will consider the option of a pool of tracking numbers connected to the VoxImplant platform, which will be responsible for handling incoming calls and redirecting them to the client number. In the call processing scenario, we will provide data for forwarding from the backend via HTTP (S) and recording call information. If the call is successful, then we will save its date, duration, call recording URL, the number to which the call came and the number to which we forwarded the call, in case the call did not take place, add the error information - why it wasn’t phoned. Let's proceed to the implementation:
  1. Register and activate your account VoxImplant
  2. Go to the control panel and create an application in the Applications section, you can call it tracking
  3. In the Scenarios section, create a new script with the following content:

    var outbound_call, dialed_number, agent_number, record_url, call_date, call_length = 0, failure_code, failure_reason, wsURL = "http://yourwebservice.com/api", // ,   -      connected = false; //    VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) { //    UTC- call_date = new Date().toUTCString(); // ,    dialed_number = e.destination; // URL         wsURL += "?dialed_number=" + encodeURIComponent(dialed_number); //  HTTP-  -,        Net.httpRequest(wsURL, function (res) { if (res.code == 200) { //     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 { //  -  -  ,   -     e.call.reject(); } }); }); //    VoxEngine.addEventListener(AppEvents.Terminating, function (e) { //      if (connected) { Logger.write("Dialed number: " + dialed_number + " Agent number: " + agent_number + " Date: " + call_date + " Length: " + call_length + " Record URL: " + record_url); //      HTTP     Net.httpRequest } else { //    Logger.write("Call failed. Code: " + failure_code + " Reason: " + failure_reason); //     HTTP     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 handleCallsConnected(call1, call2) { connected = true; outbound_call.addEventListener(CallEvents.RecordStarted, function (e) { record_url = e.url; }); outbound_call.record(); // start call recording } 

    Save it under some name. Do not forget to make your web service a return number for forwarding and change wsURL in the code
  4. Now there are 2 options with numbers - you can take them directly to VoxImplant , or in the SIP settings you can register the address of your trunk, from where the calls will go to the platform.
  5. We go into editing the tracking application that we created earlier, and there in the Rules tab we create a new rule that needs to be named somehow, for example, InboundCalls, Pattern can be left. * If we want to send all incoming calls to be processed by our script, drag the script to Assigned and save.
  6. You can call


This is the simplest scenario that shows the concept of using VoxImplant for call tracking, you can complicate it and try to call a call to several numbers at once, or try to call several numbers one at a time. If you need more rooms than you have in stock, you can always use the additional ones that the customer will enter when calling the number. In this case, the code will need to add processing keystrokes, like this:

 var inbound_call, ext = ''; //    VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) { inbound_call = e.call; inbound_call.addEventListener(CallEvents.ToneReceived, function (callevent) { callevent.call.stopPlayback(); ext += callevent.tone; if (ext.length == 4) { wsURL += "?dialed_number=" + encodeURIComponent(dialed_number) + "&ext=" + ext; //     Net.httpRequest(wsURL, function (res) { if (res.code == 200) { //     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 { //  -  -  ,   -     inbound_call.reject(); } }); } }); inbound_call.addEventListener(CallEvents.Connected, function (callevent) { inbound_call.say(",  .", Language.RU_RUSSIAN_FEMALE); }); inbound_call.answer(); }); 

Probably, you can come up with many more interesting things, but this is not included in the scope of this article. It is important to remember that a full-fledged call-tracking service requires a lot of work and ready-made services that do this do not just take money for it. I will be glad to answer any questions in the comments.

Source: https://habr.com/ru/post/250899/


All Articles