softechlog-capture
v1.0.0
Published
Auto-capture browser script — tracks clicks, navigations, forms and page views
Downloads
35
Maintainers
Readme
stl_capture.js
Auto-capture browser script for Softechlog. Tracks button clicks, link navigations, form submissions and page views automatically — no code changes needed after setup.
Usage
Add to your HTML <head>:
<script src="https://cdn.softechlog.com/[email protected]/stl_capture.js"></script>
<script>
Softechlog.init("stl_pk_xxxxxxxxxxxx");
</script>Identify the current user (call once on login / page load when user is known):
Softechlog.identify({
id: currentUser.id, // required
name: currentUser.name, // optional
email: currentUser.email, // optional
});Manual track (optional — for events outside the auto-capture scope):
Softechlog.track("custom.event", { extra: "metadata" });What gets auto-captured
| Trigger | Action name | Data |
|---------|-------------|------|
| Button click | ui.button_clicked | text, selector, page_url |
| Link click | ui.link_clicked | text, href, page_url |
| Form submit | ui.form_submitted | form name/id, page_url |
| Page view | ui.page_viewed | url, title, referrer |
Privacy controls
<!-- Exclude an element entirely -->
<button data-stl-ignore>Do not track this</button>
<!-- Suppress text content (element is tracked, text is redacted) -->
<div data-stl-mask>
<input type="text" placeholder="Sensitive field" />
</div>Flush behaviour
- Events batch in memory and flush every 2 seconds
- On page unload, flushes immediately via the Beacon API (survives tab close)
- If
identify()hasn't been called yet, actor is sent asnulluntil it is
Build
npm install
npm run build # → dist/stl_capture.js (~6KB minified+gzipped)