To run personalized marketing automation campaigns, you need access to real-time user behavior data. For online stores, this means tracking the exact steps a customer takes during the checkout process. By capturing when a user enters checkout, inputs their shipping details, and completes a payment, you can trigger targeted follow-up campaigns. In this article, we will show you how to track checkout events from Shopify, WooCommerce, or a custom Laravel store and push them to Mautic using webhooks and APIs.
1. The Checkout Funnel Events
An optimized e-commerce integration tracks three key checkout funnel stages:
- Checkout Initiated (Step 1): Triggered when a user clicks the "Proceed to Checkout" button. This captures the user's email and cart contents early.
- Shipping Info Added (Step 2): Triggered when the user enters their address details. This provides geographical data for localized tax or shipping campaigns.
- Payment Attempted/Completed (Step 3): Triggered when the payment gateway responds. This confirms the sale or flags payment failures.
2. Setting Up Webhooks in Shopify and WooCommerce
Both Shopify and WooCommerce provide built-in webhook systems that send JSON payloads when checkout events occur. Here is how to configure them:
- Shopify: In your Admin settings under Notifications, create a webhook for
Checkout Creationand point it to your integration endpoint. - WooCommerce: In your WooCommerce settings under Advanced -> Webhooks, create a webhook for
Checkout createdand configure the delivery URL.
Because these webhooks send raw payloads, you should route them through a local middleware application (such as Laravel or Node.js) instead of sending them directly to Mautic. The middleware parses the payload, extracts the customer details, and updates the contact in Mautic securely.
3. Writing the Custom Webhook Handler in Laravel
Your webhook handler should validate incoming requests to prevent spam. Below is a code example of a Laravel controller handling an incoming checkout webhook, validating the signature, and pushing the contact details to Mautic:
public function handleCheckoutWebhook(Request $request) {
// 1. Verify webhook signature
if (!$this->isValidSignature($request)) {
return response()->json(['error' => 'Unauthorized'], 401);
}
// 2. Extract customer details
$email = $request->input('email');
$firstName = $request->input('billing_address.first_name');
// 3. Queue job to sync with Mautic API
SyncMauticContactJob::dispatch($email, $firstName, [
'checkout_status' => 'initiated',
'cart_total' => $request->input('total_price')
]);
return response()->json(['status' => 'queued']);
}
Using a queued job ensures that webhook responses return immediately, preventing timeouts and protecting your store's performance.
4. Custom Contact Field Mapping in Mautic
To store this checkout data, create matching custom fields in Mautic (e.g., checkout_status, last_checkout_date, and cart_total_value). Ensure these fields are configured as "publicly editable" in the settings if you plan to update them via tracking script integrations, or keep them private if you update them exclusively via server-side API calls.
5. Triggering Campaigns Based on Funnel Events
With these fields populated, you can create segments in Mautic like "Initiated Checkout - No Purchase" or "High-Value Cart Abandoners" (e.g., cart value > $100). Use these segments to trigger automated email campaigns, personalized retargeting sequences, or send Slack alerts to your sales team to follow up manually.
If you need assistance designing secure webhook integrations or connecting your store to Mautic, visit our Mautic Customization Services or explore our Backend API Development Services.