CDN / Script Tag
For sites that don’t use a bundler — marketing pages, Webflow exports, server-rendered apps — the SDK ships an IIFE bundle that auto-initializes from data-* attributes on the loading <script> tag.
Basic install
<script
src="https://cdn.treliq.com/treliq.iife.js"
data-api-key="tk_live_xxx"
data-project-id="your-project-id"
defer
></script>
That’s it. As soon as the script runs, an SDK instance is created and exposed on window.__treliq.
All supported attributes
| Attribute | Maps to |
|---|---|
data-api-key | apiKey (required) |
data-project-id | projectId (required) |
data-api-url | apiUrl |
data-sse-url | sseUrl |
data-auto-track | autoTrack (string "true" enables) |
data-in-app | inApp.enabled (string "false" disables; any other value enables) |
Using the global
After load, identify the user and track events from any inline script:
<script>
(async () => {
await window.__treliq.identify('user_123', { email: '[email protected]' });
window.__treliq.track('page_loaded');
})();
</script>
Loading order
Use defer so the script runs after HTML is parsed but before DOMContentLoaded. If you put the tag in <head> without defer, the page render is blocked until the SDK downloads.
<!-- Recommended -->
<script src=".../treliq.iife.js" data-api-key="…" data-project-id="…" defer></script>
<!-- Or place at end of <body> without defer -->
<body>
…
<script src=".../treliq.iife.js" data-api-key="…" data-project-id="…"></script>
</body>
Self-hosting
If you’d rather not depend on a CDN, copy dist/treliq.iife.js from the npm package into your static assets and serve it from your own origin.
npm install @treliq/sdk
cp node_modules/@treliq/sdk/dist/treliq.iife.js public/js/
<script src="/js/treliq.iife.js" data-api-key="…" data-project-id="…" defer></script>
Tag managers (GTM, Tealium)
The IIFE bundle works in any tag manager — paste it into a Custom HTML tag with the appropriate triggers. Identify users in a separate tag that fires after authentication state is known.
<!-- GTM Custom HTML: load SDK -->
<script
src="https://cdn.treliq.com/treliq.iife.js"
data-api-key="{{Treliq API Key}}"
data-project-id="{{Treliq Project ID}}"
defer
></script>
<!-- GTM Custom HTML: identify (fires after login event) -->
<script>
if (window.__treliq) {
window.__treliq.identify({{User ID}}, {
email: {{User Email}},
plan: {{User Plan}},
});
}
</script>