Skip to content
Documentation menu: Installation

Install in about 2 minutes

Let your AI coding agent do it, or paste one script tag. About 5 KB gzipped, no IP addresses stored, works on any site that can add a script.

Fastest

Use your AI coding agent

Paste this prompt into Claude Code, Cursor, Codex, Copilot or any coding agent opened in your site's repository. It adds the script, ties Stripe or Whop checkouts to visits if you use them, and tracks signups as conversions. Your dashboard's Setup page has the same prompt with your website ID and domain filled in.
Install theBizness.ai analytics in this project. Keep the change minimal.

1. Tracking script (required)
Load this script once on every page, in the <head> of the root layout or main HTML template:

<script defer data-website-id="your-website-id" data-domain="yourdomain.com" src="https://thebizness.ai/js/script.js"></script>

- Next.js: use next/script with strategy="afterInteractive" and the same data-* attributes, in app/layout.tsx (App Router) or pages/_app.tsx (Pages Router).
- Anything else: the shared template that renders <head> (index.html, base layout, theme header).
- Do not change the src or the attribute values.

2. Revenue (only if this project takes payments with Stripe Checkout or Whop)
Find every place that starts a checkout (stripe.checkout.sessions.create, whop.checkoutConfigurations.create, or an embedded Whop checkout that takes metadata in the browser), including fallback and retry paths, and add this metadata to each:
metadata: {
  websiteId: 'your-website-id',
  visitorId: <value of the thebizness_visitor_id cookie>,
  sessionId: <value of the thebizness_session_id cookie>
}
- Read the two cookies at the moment the checkout is created or opened, not when the page first loads: the tracking script sets them a moment after the page loads, so a value read at page load is missing for a new visitor who checks out right away. On a server, read them from the incoming request; in the browser, from document.cookie (URL-decoded).
- Always include websiteId. If a cookie is missing, leave that field out but still create the checkout; never block or delay a checkout for analytics.
- Keep any metadata the checkout already sends.
- For a Stripe session with mode 'subscription', also set subscription_data: { metadata: <the same object> }.
- If a checkout path cannot carry metadata (for example a plain link to a hosted checkout page), leave it as it is and name it in your summary.

3. Conversions (optional, only where the user completes a goal in client-side code, such as a signup)
Right after the action succeeds, call:
// Queues calls made before the tracking script has loaded
window.thebizness=window.thebizness||function(){(window.thebizness.q=window.thebizness.q||[]).push(arguments)};
window.thebizness('conversion', { name: 'Signup' });

When you are done, list the files you changed. I will deploy and open yourdomain.com to confirm the first pageview arrives.

By hand

Paste the script tag

Add it to the <head> of the template every page uses. Replace the two values with yours, or copy the filled-in version from the Setup page.
<script
  defer
  data-website-id="your-website-id"
  data-domain="yourdomain.com"
  src="https://thebizness.ai/js/script.js">
</script>

Platform guides

Exact steps for your framework or site builder.

  • Google Tag Manager

    1. Open your container and choose Add a new tag.
    2. Choose Custom HTML as the tag type and paste the script tag.
    3. Set the trigger to All Pages, name the tag, then save and publish the container.
  • Plain HTML

    1. Open the template or page every URL shares (often index.html or a layout partial).
    2. Paste the script tag just before the closing head tag, and upload the file.
  • Framer

    1. Open Site Settings, then General, then Custom Code.
    2. Paste the script tag in the Start of head tag section and save.
    3. Publish the site. Custom code only runs on a published site, not in the preview.
  • Wix

    1. Open Settings, then Custom Code (under Advanced), then Add Custom Code. This needs a Premium plan.
    2. Paste the script tag, set Add Code to Pages to All pages and Place Code in to Head.
    3. Apply and publish the site.
  • Squarespace

    1. Open Settings, then Developer Tools, then Code Injection. This needs a Business plan or higher.
    2. Paste the script tag in the Header box and save.
  • Webflow

    1. Open Project Settings and choose the Custom Code tab. Custom code needs a paid site plan.
    2. Paste the script tag in the Head Code section.
    3. Save the settings and publish your site.
  • Ghost

    1. In Ghost Admin, open Settings and choose Code Injection.
    2. Paste the script tag in the Site Header section and save.
  • Shopify

    1. Open Online Store, then Themes, then Actions and Edit code.
    2. In the Layout folder, open theme.liquid and paste the script tag just before the closing head tag. Use {{ shop.domain }} as the data-domain value.
    3. Save the file.

Check it works

The same two steps for every platform.

Publish, open your live site in a new tab, then reload your dashboard. Your own visit appears as a pageview. The script does nothing on localhost, *.local, *.test, private IP addresses or file:// pages, so test on the real domain.

Nothing showing up?

  • Add data-debug="true" to the tag and watch the browser console. It says why an event was not recorded.
  • Ad blocker: the visit is blocked in your own browser. Test in a private window without extensions, or proxy the script through your own domain.
  • Content-Security-Policy: allow https://thebizness.ai in script-src and connect-src. Blocked requests show only as CSP errors in the console.
  • Check that data-website-id is yours (not the placeholder) and that data-domain matches the site you opened.
  • Site builders only run custom code on the published site, and some need a paid plan (see the steps above).

Next: connect revenue, tag your campaign links, or send events from your server.

Script attributes

Everything the script reads from its own tag
  • data-website-idRequired. Your website ID. Without it the script does nothing.
  • data-domainYour website's domain. Recommended: it is used to tell internal navigation from external referrers. Sites on shared hosting domains (vercel.app, github.io and similar) are treated per project, not per platform: my-app.vercel.app and other-project.vercel.app are different sites.
  • data-cookie-domainOptional. A parent domain such as example.com. The visitor and session cookies are then shared across its subdomains, so a visitor who moves between www, shop and app stays one visitor. Without it the cookies belong to the exact host. The value is ignored unless the page is on that domain and the browser accepts a cookie for it.
  • data-hash-routingOptional. true also counts fragment routes without a slash, such as #about, as pageviews; false counts no fragments. By default only route-like fragments such as #/pricing are counted. A route without a slash is reported with one (#about appears as /#/about in your reports). Fragments that contain = or & or are longer than 100 characters are never counted, and the query inside a route is never sent.
  • data-debugOptional. true logs what the script sends and why an event was not recorded (for example origin_not_allowed or plan_limit) in the browser console.

Optional: proxy the script past ad blockers

Serve the script and its requests from your own domain (or a subdomain such as analytics.yourdomain.com), so fewer ad blockers block them.

Any reverse proxy must forward all of /api/events/*, including the conversion paths, must keep the visitor's Origin or Referer header, and should remove the Cookie and Authorization headers before forwarding. All visitors then reach us from your proxy's address, so the per-address rate limits apply to your site as a whole. Recipes cover Next.js middleware, nginx and Cloudflare Workers.

See the proxy recipes

Frequently asked questions

How much does the script impact page speed?

The script is about 5 KB gzipped and loads without blocking the page, so its effect on page load is small.

Does the script set cookies?

Yes. It sets two first-party cookies on your domain: thebizness_visitor_id (365 days) and thebizness_session_id (one hour after the last tracked activity). They belong to the exact host unless you set data-cookie-domain to share them across your subdomains. It also uses localStorage (thebizness_utm and thebizness_referrer_data) for UTM and referrer data used for attribution for up to 30 days (the entry stays in the browser until it is replaced or cleared). Safari (macOS and iOS) and Brave cap cookies written by JavaScript at about 7 days, and Safari also clears localStorage after 7 days without a visit, so visitors who return later in those browsers can show as new visitors. The proxy setup does not lift this. It sets no third-party cookies.

Can I track multiple websites?

Yes, each website gets its own unique tracking ID. You can manage multiple sites from one dashboard.

Does my site need a Content-Security-Policy change?

Only if your site sends a Content-Security-Policy header. Allow https://thebizness.ai in script-src (to load the script) and connect-src (to send data). An inline window.thebizness stub needs a nonce or hash under script-src. The proxy setup needs only 'self'.

Does the script collect personal data?

It does not store IP addresses with events. It stores persistent visitor and session IDs with each event. Whether you need consent before the script runs depends on your jurisdiction, and that decision is yours. See the privacy guide for details.

What about ad blockers?

Some ad blockers block the standard script. The proxy setup serves it from your own domain, which reduces that blocking. Conversion tracking needs the conversion paths proxied too; the proxy setup in the Next.js guide covers them.

Need help with installation?

Email us at [email protected] and we'll help you get set up.