Get started
Quick start
From signup to a banner rendered on your own page in about five minutes.
By the end you will have a banner, written by Tug and approved by you, rendering on a page you control. You need a browser and a terminal. No deploy.
Create a project
Sign up and finish onboarding. It creates your first project. Leave Origin URL blank for now, so pages on
localhost(or a file you open from disk) can call the API.The project page shows your public key (
phk_live_…). Copy it: every snippet below needs it. It is safe to put in browser code.Load demo data
On the project page, click Load demo data. It sends sample events for the user
folio_demo_user, creates a starter goal ("finish signing up") and runs intelligence, which drafts messages. That run isn't billed.Approve a banner
Open Recommendations. Under Waiting for review, pick a banner draft, edit the copy if you like, and approve it.
To check, use Preview decision on the project page with user ID
folio_demo_userand surface Banner. You should see your copy.Render it on a page
Save this as
index.html, put your public key in, and open it in a browser. The banner renders and reports itself as shown.Render the banner<link rel="stylesheet" href="https://tughq.com/tug.css"> <div id="tug-banner"></div> <script src="https://tughq.com/tug-embed.js"></script> <script> Tug.mountBanner("#tug-banner", { publicKey: "phk_live_…", userId: "folio_demo_user", }); </script>Send your own events
Now point it at real users. Add the script tag to every page of your app. It records pageviews on its own.
In your <head> · HTML
<script src="https://tughq.com/tug.js" defer></script> <script> window.tugConfig = { publicKey: "phk_live_…" }; </script>After login, tell Tug who the visitor is, and track the moments that matter:
After login · JavaScript
// After login: switch from the anonymous visitor ID to your user ID tug.identify("user_123", { plan: "trial" }); // Custom events for the current user (no user ID needed) tug.track("pricing_viewed", { plan: "pro" });Or check your key from a terminal first. The event appears under Recent events on the project page within seconds.
Send one event · Shell
curl -X POST "https://tughq.com/api/v1/events" \ -H "Content-Type: application/json" \ -d '{ "publicKey": "phk_live_…", "distinctId": "user_123", "name": "signup_completed" }' # → {"ok":true,"accepted":1,"duplicates":0,"suppressed":0}Set a goal
On Goals, describe what you want users to do and pick its target event (for example
signup_completed). Then click Run intelligenceon the project page, or wait for the daily run. Approve the drafts you like, and render them with the same snippet as step 4, using your user's ID.
Next steps#
- React or Node: install for your stack.
- Identity verification: stop anyone with your public key from reading other users' messages. Do this before launch.
- Environments: a separate project for staging.
- PostHog: forward the events you already collect.