Add lead tracking webhook implementation
This commit is contained in:
parent
76e975bd18
commit
3cc601900b
|
|
@ -6,6 +6,7 @@ use App\Http\Requests\StoreUserLeadRequest;
|
|||
use App\Models\UserLead;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class UserLeadController extends Controller
|
||||
{
|
||||
|
|
@ -15,7 +16,9 @@ class UserLeadController extends Controller
|
|||
public function store(StoreUserLeadRequest $request): RedirectResponse|Response
|
||||
{
|
||||
$validated = $request->validated();
|
||||
UserLead::create($validated);
|
||||
$lead = UserLead::create($validated);
|
||||
|
||||
$this->trackLeadCreatedEvent($validated['email']);
|
||||
|
||||
$redirectUrl = config('landing.lead_redirect_url');
|
||||
|
||||
|
|
@ -27,4 +30,19 @@ class UserLeadController extends Controller
|
|||
|
||||
return to_route('home')->with('success', 'Thank you for your interest!');
|
||||
}
|
||||
|
||||
protected function trackLeadCreatedEvent(string $email): void
|
||||
{
|
||||
$eventUuid = config('landing.lead_funnel_event_uuid');
|
||||
|
||||
if (! $eventUuid || app()->environment('local', 'testing')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Http::withoutVerifying()
|
||||
->timeout(5)
|
||||
->post("https://metricswave.com/webhooks/{$eventUuid}", [
|
||||
'step' => 'Lead Created',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,15 @@ return [
|
|||
|
||||
'lead_redirect_url' => env('LEAD_REDIRECT_URL', null),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Lead Funnel Event UUID
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The MetricsWave event UUID for tracking lead funnel events.
|
||||
|
|
||||
*/
|
||||
|
||||
'lead_funnel_event_uuid' => env('LEAD_FUNNEL_EVENT_UUID', '9668a06c-dee9-47a8-9bee-eaaa2a3a5915'),
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -173,13 +173,6 @@ export default function Welcome({
|
|||
<Form
|
||||
{...store.form()}
|
||||
className="flex sm:items-center justify-center flex-col gap-2 sm:flex-row"
|
||||
onSuccess={async () => {
|
||||
const emailValue = emailInputRef.current?.value || '';
|
||||
await trackEvent(LEAD_FUNNEL_EVENT_UUID, {
|
||||
step: 'Lead Created',
|
||||
email: emailValue,
|
||||
});
|
||||
}}
|
||||
>
|
||||
{({ processing, errors }) => (
|
||||
<>
|
||||
|
|
|
|||
Loading…
Reference in New Issue