I have it so the user can purchase a new number (serving as a tracking number) and then link that number to a chosen "destination number". When the purchased tracking number is called, I have it POST the destination number to a call handling php file - there the TwiML will then <Dial>
that number, making it appear as though the tracking number is the caller.
My question is, is this an appropriate way to set up tracking numbers? My main gripe is that with the call reporting that I'm making alongside this, that <Dial>
shows up as an outgoing call, essentially making it so I'm double counting each call (since it also see's the initial call to the tracking number).
Any advice on whether or not this is the best way to approach this? It's functional, but I don't have enough experience to know whether it's the best way to do it.
If I am understanding your use case correctly, then I think this Call Tracking tutorial could help you make some architectural decisions. These tutorials are considered production ready code samples that you can run with or change based upon the needs of your application.
The main idea here is the LeadSource model which associates a Twilio number (tracking number) to a named lead source (like "Wall Street Journal Ad" or "Dancing guy with sign"). It also tracks a phone number to which we'd like all the calls redirected (your destination number), like your sales or support help line. And provides a convenience method to find leads (calls) associated with this lead source (the Twilio number).
Take a look at the full code in the docs as mentioned above and let me know if this helps at all.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Lead;
class LeadSource extends Model
{
protected $fillable = ['number', 'forwarding_number', 'description'];
public function leads()
{
return $this->hasMany('App\Lead');
}
}