Track signups with Laravel
Exempt Chartsy’s cookies from encryption, then listen for the Registered event.
Before you start
The Chartsy script must already be on every page of your site, including the app where signup happens - it supplies where the visitor came from; this guide only adds the email. See the installation guides.
1Add your secret key
Store the site's secret key in .env and expose it through config/services.php.
CHARTSY_SECRET_KEY=your_secret_key'chartsy' => [
'secret' => env('CHARTSY_SECRET_KEY'),
],3Listen for the Registered event
Breeze, Jetstream and Fortify all fire it.
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Http;
class SendSignupToChartsy
{
public function handle(Registered $event): void
{
$json = fn ($name) => json_decode(urldecode(request()->cookie($name, '')), true) ?: [];
$first = $json('chartsy_attrib');
Http::withToken(config('services.chartsy.secret'))
->timeout(3)
->post('https://dashboard.chartsy.app/api/attribution/identify/', [
'email' => $event->user->email,
'attribution_first' => (object) $first,
'attribution_last' => (object) ($json('chartsy_attrib_last') ?: $first),
'visitor_id' => request()->cookie('chartsy_visitor_id', ''),
]);
}
}


4Socialite signups
Socialite logins don't fire
Registeredunless you dispatch it. Do so where your callback creates the user ($user->wasRecentlyCreated).