identify() call for the signed-in user, and calling reset() when the user logs out. This page shows the pattern in plain HTML, Rails, Django and Laravel. The same pattern works in any server that renders HTML templates, such as ASP.NET, Express or PHP.
HTML install at a glance
- The tag goes in the
<head>of your base layout, the template every page shares. - Your server prints the
identify()call into the page, only when someone is signed in. - User values go into the page through your framework’s JSON helper, never pasted into the script by hand.
reset()runs in the browser when the user submits your logout form.- With Turbo, htmx or a similar library, keep the identify script in the body so it runs on each visit.
Before you start
- Your project key, from Settings → Setup & API Key. It is public, which means that it is safe to put in your pages.
- Access to your base layout, for example
application.html.erb,base.htmlorapp.blade.php. - About 10 minutes.
How to install HelpAlive in a server-rendered app
1
Add the tag to your base layout
Paste the tag before Replace
</head> in the layout every page uses:YOUR_PROJECT_KEY with your key.2
Print identify() for the signed-in user
In the same layout, just inside Leave out
<body>, print the identify call when someone is signed in. The first lines let the call run before our script has finished loading, and our script replays it when it arrives. Pick your framework:- Rails
- Django
- Laravel
- Plain HTML
app/views/layouts/application.html.erb
tenantId and tenantName in a B2C app, and delete the fields your app doesn’t have. Identify users describes each field.3
Call reset() when the user logs out
Logout in a server-rendered app is usually a form or a link that goes to the server. Call Use your own logout form’s selector. For a logout link, listen for
reset() in the browser just before it leaves, in the same layout:click on the link instead. If your app ends sessions on its own, for example after a timeout, also print HelpAlive.reset() on the page that tells the user they were signed out.Why print user values with a JSON helper?
Names and emails come from your users, so a value can contain characters that end a script early, such as</script>. Rails’s json_escape, Django’s json_script and Laravel’s @json turn each value into safe JavaScript. Pasting values into the script by hand would let a value someone typed into your app, such as a company name, run code in other people’s browsers.
Does it work with Turbo or htmx?
Yes. The tag in the head loads once and stays as Turbo or htmx swaps the page. Keep the identify script in the body, as above, so it runs again on each visit; a repeated call with the same details is harmless. HelpAlive records a page view by itself each time the address changes.Does the agent appear on signed-out pages?
No. The script can load on every page, but the agent appears only afteridentify() has run for a signed-in user. Your login page and marketing pages stay as they are.
Check that it works
Sign in to your app with a test account, then open Settings → Setup & API Key on the dashboard. The first step, Add HelpAlive to your app, gets a check once HelpAlive has seen your page and a signed-in user. Check it works explains each step. To see what HelpAlive does on a page, adddata-debug to the tag while you test, and remove it before you ship.
Related pages
Verify users
Sign each user id on your server, with Ruby, Python and PHP examples.
Google Tag Manager
Install without changing your templates.
Troubleshooting
The failures that show no error.

