Widget and signed-in users
The website widget gives your visitors chat, your help centre and a way to leave a message, on every page of your site. This guide adds it, then shows how to make it recognise your signed-in users, so your team sees who they’re talking to and the customer never has to type their name or email.
Add the widget
Section titled “Add the widget”Paste this before </body> on every page, with your product’s public ID (prod_…, from Website widget → Install in the dashboard):
<script src="https://dashboard.supportaka.com/widget.js" data-product="prod_YOUR_PUBLIC_ID" async></script>The widget only loads on the websites you allow for the product, set in the product’s settings in the dashboard. The Install tab also has steps for WordPress, Shopify, Wix, Squarespace and Webflow.
Recognise signed-in users
Section titled “Recognise signed-in users”Anyone can type a name and email into a chat. Identity verification lets your server vouch for who a visitor is instead: your backend signs a short-lived token for the signed-in user, and the widget passes it to Supportaka. The customer is found (or created) with your user’s ID, and their name and email are trusted because you signed them.
-
Turn it on. In the dashboard, open Website widget → Signed-in visitors and choose Turn on. Copy the identity secret: it’s shown once. Only owners can do this. Store it on your server as
SUPPORTAKA_IDENTITY_SECRET. -
Sign a token on your server for the signed-in user. It’s a JWT signed with
HS256and these claims:Claim Value aud"supportaka"pidYour product’s public ID ( prod_…)subYour own stable user ID, as a string. It’s how the same person is found next time emailOptional. Trusted as verified nameOptional iat,expIssued and expiry times, at most 10 minutes apart // npm install jsonwebtokenimport jwt from 'jsonwebtoken';export function supportakaToken(user) {return jwt.sign({aud: 'supportaka',pid: 'prod_YOUR_PUBLIC_ID',sub: String(user.id),email: user.email,name: user.fullName,},process.env.SUPPORTAKA_IDENTITY_SECRET,{ algorithm: 'HS256', expiresIn: '10m' },);}# pip install pyjwtimport os, time, jwtdef supportaka_token(user):now = int(time.time())return jwt.encode({"aud": "supportaka","pid": "prod_YOUR_PUBLIC_ID","sub": str(user.id),"email": user.email,"name": user.full_name,"iat": now,"exp": now + 600,}, os.environ["SUPPORTAKA_IDENTITY_SECRET"], algorithm="HS256")// composer require firebase/php-jwtuse Firebase\JWT\JWT;function supportaka_token($user) {$now = time();return JWT::encode(['aud' => 'supportaka','pid' => 'prod_YOUR_PUBLIC_ID','sub' => (string) $user->id,'email' => $user->email,'name' => $user->name,'iat' => $now,'exp' => $now + 600,], getenv('SUPPORTAKA_IDENTITY_SECRET'), 'HS256');} -
Hand it to the widget on pages where the user is signed in, after the widget’s script tag:
<script>window.Supportaka = window.Supportaka || [];window.Supportaka.push(['identify', '<?= supportaka_token($user) ?>']);</script>Render the token into the page from your server, or fetch it from an endpoint of yours that only answers signed-in users. It’s fine to call
identifyafter the widget has started, for example right after the user signs in.
Good to know
Section titled “Good to know”- Tokens are short-lived (10 minutes at most), so make a new one per page load or session refresh. An expired or badly signed token is silently ignored and the visitor stays anonymous; the widget never says why, so check your claims and secret if users aren’t recognised.
subis the key. Use an ID that never changes (not the email). If a customer with that email already exists, they’re linked to yoursub.- Nothing the browser says is trusted without your signature, so a visitor can’t pretend to be someone else.
- The customer then shows up in the API like any other: sync customers to add your own fields and labels.