Created
June 24, 2012 20:42
-
-
Save RobSpectre/2984829 to your computer and use it in GitHub Desktop.
Call Tracking Demo for Organic versus Paid Search visitors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define Twilio number you wish to use for call tracking | |
$ORGANIC = '+18475625924'; | |
$PAID = '+18475625918'; | |
// Set your account credentials and numbers you want to call and text. | |
$ACCOUNT_SID = "ACxxxxxxxxx"; | |
$AUTH_TOKEN = "yyyyyyyyyyyy"; | |
$TWILIO_NUMBER = "+12223334444"; | |
$NUMBER_TO_CALL = "+15556667777"; | |
$NUMBER_TO_TEXT = "+15554443333"; | |
// Get Twilio PHP helper library and instantiate client | |
require_once('Services/Twilio.php'); | |
$client = new Services_Twilio($ACCOUNT_SID, $AUTH_TOKEN); | |
// Get the tracking number the user is calling | |
$to = $_REQUEST['To']; | |
// If organic, notify that an organic lead has come in - otherwise say paid search | |
if ($to == $ORGANIC) { | |
$msg = $client->account->sms_messages->create( | |
$ORGANIC, | |
$NUMBER_TO_TEXT, | |
"You received a new organic lead." | |
); | |
} else { | |
$msg = $client->account->sms_messages->create( | |
$PAID, | |
$NUMBER_TO_TEXT, | |
"You received a new paid search lead." | |
); | |
} | |
// Connect user with the office. | |
?> | |
<Response> | |
<Dial><Number><?php echo $NUMBER_TO_CALL; ?></Number></Dial> | |
</Response> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment