ActessiaBook a 30-day pilot
Integration guide

Laravel

A Blade component that signs identify() with a helper, the tag in the layout, reset on logout.

1. The signing helper

Copy actessia_sign_identify from the identify() page into app/Support/actessia.php (PHP 8.1+, no dependencies) and add it to composer.json autoload files. Put the secret in .env as ACTESSIA_IDENTIFY_SECRET and read it through config/services.php.

2. A Blade component

// app/View/Components/Actessia.php
public function render()
{
    $user = auth()->user();
    $signed = $user ? actessia_sign_identify(config('services.actessia.identify_secret'), [
        'user_id' => (string) $user->id, 'email' => $user->email, 'plan' => $user->plan, 'issued_at' => time(),
    ]) : null;
    return view('components.actessia', ['signed' => $signed, 'siteKey' => config('services.actessia.site_key')]);
}
{{-- resources/views/components/actessia.blade.php --}}
<script>window.Actessia=window.Actessia||{q:[]};["identify","track","setContext","escalate","open","close","reset"].forEach(function(m){window.Actessia[m]=function(){window.Actessia.q.push([m,[].slice.call(arguments)])}});</script>
@if($signed)
<script>Actessia.identify(@json($signed['payload']), @json($signed['signature']));</script>
@endif
<script async src="https://cdn.actessia.ai/v1/actessia.js" data-site-key="{{ $siteKey }}"></script>

Include <x-actessia /> once, at the end of the layout's <body>.

3. Logout

Call Actessia.reset() on the page the logout lands on.

4. Conversions from the server

Http::withToken(config('services.actessia.server_key'))
    ->post('https://api.actessia.ai/v1/webhooks/conversions', [
        'user_id' => (string) $user->id,
        'event' => ['event' => 'upgrade', 'event_id' => $invoice->id, 'value_cents' => $invoice->total_cents, 'currency' => 'EUR'],
    ]);