mrustamzade / laravel-marketing-touchpoints
Laravel package to track marketing touchpoints and connect them to orders.
Package info
github.com/byrustamzade/prou-marketing
pkg:composer/mrustamzade/laravel-marketing-touchpoints
Requires
- php: ^8.2
- illuminate/database: ^10.0|^11.0|^12.0
- illuminate/http: ^10.0|^11.0|^12.0
- illuminate/routing: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
- illuminate/view: ^10.0|^11.0|^12.0
This package is auto-updated.
Last update: 2026-05-16 10:58:45 UTC
README
Track user marketing touchpoints (including UTM params) with a unique visitor token, then link the final order to that token after checkout.
Features
- Generates a unique token cookie when a visitor arrives.
- Stores each touchpoint in DB with URL, path, referrer, UTM data, and request metadata.
- Links orders to the same visitor token after checkout.
- Supports custom order table and primary key resolution.
- Includes an admin route (
/marketing) for viewing touchpoints by token or order ID.
Screenshot
Installation
composer require mrustamzade/laravel-marketing-touchpoints
Publish config and migrations:
php artisan vendor:publish --tag=marketing-touchpoints-config php artisan vendor:publish --tag=marketing-touchpoints-migrations
Run migrations:
php artisan migrate
Enable Tracking Middleware
Option 1: Enable auto-injection in config:
'middleware' => [ 'auto_track_web' => true, ],
Option 2: Add alias manually to your routes/group:
Route::middleware(['web', 'track-touchpoints'])->group(function (): void { // your storefront routes });
Link Order After Checkout
In checkout success flow:
use MRustamzade\MarketingTouchpoints\Facades\MarketingTouchpoints; MarketingTouchpoints::linkOrder($order); // Eloquent model
Or scalar order ID:
MarketingTouchpoints::linkOrder($orderId);
Or pass full order reference:
MarketingTouchpoints::linkOrder([ 'table' => 'shop_orders', 'primary_key' => 'uuid', 'id' => $orderUuid, ]);
Optional model trait
Add this to your order model to auto-link when created:
use MRustamzade\MarketingTouchpoints\Concerns\LinksMarketingTouchpoints; class Order extends Model { use LinksMarketingTouchpoints; }
Order Table + Primary Key Resolution
The package resolves order reference in this order:
- If you pass an Eloquent model to
linkOrder(), it uses that model's table and key name. - Else if
orders.modelis configured, it loads table/key from that model. - Else it falls back to
orders.tableandorders.primary_key.
Set defaults in config/marketing-touchpoints.php:
'orders' => [ 'model' => App\Models\Order::class, 'table' => 'orders', 'primary_key' => 'id', ],
Admin Marketing Route
Default route:
- URL:
/marketing - middleware:
web,auth - filters:
?token={token}or?order_id={orderId}
Customize from config:
'route' => [ 'prefix' => 'marketing', 'middleware' => ['web', 'auth'], ],
Config Summary
tables.visitors,tables.touchpoints,tables.conversionsorders.model,orders.table,orders.primary_keymiddleware.exceptto skip tracking admin/internal routestrack.only_with_utmif you only want UTM-tagged touchpointstrack.dedupe_secondsto skip identical rapid reloads (set0to disable)
