Set up SourceTrack with an AI site builder

Copy-paste prompts that tell Lovable, Bolt, Replit or v0 to install the SourceTrack tracking script, and optionally to send conversions.

Agent guidance

  • Only the public site key goes into the builder chat and into the page. Find it in the app at Setup, Install (https://app.sourcetrack.ai/setup).
  • Never paste a server API token (it starts with st_live_) into a builder chat, a prompt, a code file or an environment variable that ships to the browser. The browser needs no token.
  • Use the root-alias script URL https://api.srctk.com/tracker.min.js. Add the tag once.

What the prompt installs

One script tag, which loads the tracker from SourceTrack and identifies your site by its public site key:

<script async src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY"></script>

For Next.js the same script is loaded with next/script:

import Script from 'next/script'

// inside <body> in app/layout.tsx, after {children}
<Script
  src="https://api.srctk.com/tracker.min.js"
  data-site-key="YOUR_SITE_KEY"
  strategy="afterInteractive"
/>

If your site uses a custom tracking domain, copy the exact snippet from Setup in the app instead: it already points at the right host.

Prompts

Replace PASTE_YOUR_SITE_KEY_HERE with your own site key before you send a prompt. Each prompt asks the builder to work out its own project type, so the same text works whichever builder you use.

Lovable

Paste this into the Lovable chat after replacing PASTE_YOUR_SITE_KEY_HERE with your site key:

Add SourceTrack analytics to this Lovable project.

My SourceTrack site key is: PASTE_YOUR_SITE_KEY_HERE
This is a PUBLIC site key. It is meant to appear in the page source. Use only this value.

Do exactly this:
1. Work out what kind of project this is.
   - Plain HTML, or a Vite or other single-page app with an index.html: add this one tag inside the <head> of index.html:
     <script async src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY"></script>
   - Next.js App Router: in app/layout.tsx add this inside <body>, after {children}:
     <Script src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY" strategy="afterInteractive" />
     and import Script from "next/script".
   - Anything else: put the same script tag in the single HTML shell that every page shares.
2. Replace YOUR_SITE_KEY with my site key. Keep the src URL and the attribute names exactly as written. Add the tag in one place only, once.
3. Do not add cookies, a consent banner, or any other tracking code.
4. Do not ask me for, and never use, any server API token or secret key (anything starting with st_live_). Do not put a token in the code, in an environment variable, or in this chat. Only the public site key belongs in the browser.
5. Tell me which file you changed.

When you are done, I will publish, open my live site on the domain I registered in SourceTrack, and check that a request to /api/track completes.

Optional, to send conversions. Paste this as a second message:

Now send conversions to SourceTrack from this Lovable project. The tracking script is already installed.

Call window.sourcetrack.conversion(...) only after the action has really succeeded (the signup is saved, the form is accepted, the payment is confirmed), and guard it because the script loads asynchronously:

if (window.sourcetrack) {
  window.sourcetrack.conversion({ type: 'lead' })
}

- Lead or signup: type "lead" or "signup". Send no value.
- Purchase: type "purchase", with order_id set to the real order or payment id, value set to the real amount, and currency set to its three-letter code. Never invent or estimate a value.
- Do not put an email address, name, phone number or any other personal data in the call.
- Do not use any server API token or secret key here, and do not ask me for one. The browser call needs no key beyond the site key already in the script tag.

Bolt

Paste this into the Bolt chat after replacing PASTE_YOUR_SITE_KEY_HERE with your site key:

Add SourceTrack analytics to this Bolt project.

My SourceTrack site key is: PASTE_YOUR_SITE_KEY_HERE
This is a PUBLIC site key. It is meant to appear in the page source. Use only this value.

Do exactly this:
1. Work out what kind of project this is.
   - Plain HTML, or a Vite or other single-page app with an index.html: add this one tag inside the <head> of index.html:
     <script async src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY"></script>
   - Next.js App Router: in app/layout.tsx add this inside <body>, after {children}:
     <Script src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY" strategy="afterInteractive" />
     and import Script from "next/script".
   - Anything else: put the same script tag in the single HTML shell that every page shares.
2. Replace YOUR_SITE_KEY with my site key. Keep the src URL and the attribute names exactly as written. Add the tag in one place only, once.
3. Do not add cookies, a consent banner, or any other tracking code.
4. Do not ask me for, and never use, any server API token or secret key (anything starting with st_live_). Do not put a token in the code, in an environment variable, or in this chat. Only the public site key belongs in the browser.
5. Tell me which file you changed.

When you are done, I will publish, open my live site on the domain I registered in SourceTrack, and check that a request to /api/track completes.

Optional, to send conversions. Paste this as a second message:

Now send conversions to SourceTrack from this Bolt project. The tracking script is already installed.

Call window.sourcetrack.conversion(...) only after the action has really succeeded (the signup is saved, the form is accepted, the payment is confirmed), and guard it because the script loads asynchronously:

if (window.sourcetrack) {
  window.sourcetrack.conversion({ type: 'lead' })
}

- Lead or signup: type "lead" or "signup". Send no value.
- Purchase: type "purchase", with order_id set to the real order or payment id, value set to the real amount, and currency set to its three-letter code. Never invent or estimate a value.
- Do not put an email address, name, phone number or any other personal data in the call.
- Do not use any server API token or secret key here, and do not ask me for one. The browser call needs no key beyond the site key already in the script tag.

Replit

Paste this into the Replit chat after replacing PASTE_YOUR_SITE_KEY_HERE with your site key:

Add SourceTrack analytics to this Replit project.

My SourceTrack site key is: PASTE_YOUR_SITE_KEY_HERE
This is a PUBLIC site key. It is meant to appear in the page source. Use only this value.

Do exactly this:
1. Work out what kind of project this is.
   - Plain HTML, or a Vite or other single-page app with an index.html: add this one tag inside the <head> of index.html:
     <script async src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY"></script>
   - Next.js App Router: in app/layout.tsx add this inside <body>, after {children}:
     <Script src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY" strategy="afterInteractive" />
     and import Script from "next/script".
   - Anything else: put the same script tag in the single HTML shell that every page shares.
2. Replace YOUR_SITE_KEY with my site key. Keep the src URL and the attribute names exactly as written. Add the tag in one place only, once.
3. Do not add cookies, a consent banner, or any other tracking code.
4. Do not ask me for, and never use, any server API token or secret key (anything starting with st_live_). Do not put a token in the code, in an environment variable, or in this chat. Only the public site key belongs in the browser.
5. Tell me which file you changed.

When you are done, I will publish, open my live site on the domain I registered in SourceTrack, and check that a request to /api/track completes.

Optional, to send conversions. Paste this as a second message:

Now send conversions to SourceTrack from this Replit project. The tracking script is already installed.

Call window.sourcetrack.conversion(...) only after the action has really succeeded (the signup is saved, the form is accepted, the payment is confirmed), and guard it because the script loads asynchronously:

if (window.sourcetrack) {
  window.sourcetrack.conversion({ type: 'lead' })
}

- Lead or signup: type "lead" or "signup". Send no value.
- Purchase: type "purchase", with order_id set to the real order or payment id, value set to the real amount, and currency set to its three-letter code. Never invent or estimate a value.
- Do not put an email address, name, phone number or any other personal data in the call.
- Do not use any server API token or secret key here, and do not ask me for one. The browser call needs no key beyond the site key already in the script tag.

v0

Paste this into the v0 chat after replacing PASTE_YOUR_SITE_KEY_HERE with your site key:

Add SourceTrack analytics to this v0 project.

My SourceTrack site key is: PASTE_YOUR_SITE_KEY_HERE
This is a PUBLIC site key. It is meant to appear in the page source. Use only this value.

Do exactly this:
1. Work out what kind of project this is.
   - Plain HTML, or a Vite or other single-page app with an index.html: add this one tag inside the <head> of index.html:
     <script async src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY"></script>
   - Next.js App Router: in app/layout.tsx add this inside <body>, after {children}:
     <Script src="https://api.srctk.com/tracker.min.js" data-site-key="YOUR_SITE_KEY" strategy="afterInteractive" />
     and import Script from "next/script".
   - Anything else: put the same script tag in the single HTML shell that every page shares.
2. Replace YOUR_SITE_KEY with my site key. Keep the src URL and the attribute names exactly as written. Add the tag in one place only, once.
3. Do not add cookies, a consent banner, or any other tracking code.
4. Do not ask me for, and never use, any server API token or secret key (anything starting with st_live_). Do not put a token in the code, in an environment variable, or in this chat. Only the public site key belongs in the browser.
5. Tell me which file you changed.

When you are done, I will publish, open my live site on the domain I registered in SourceTrack, and check that a request to /api/track completes.

Optional, to send conversions. Paste this as a second message:

Now send conversions to SourceTrack from this v0 project. The tracking script is already installed.

Call window.sourcetrack.conversion(...) only after the action has really succeeded (the signup is saved, the form is accepted, the payment is confirmed), and guard it because the script loads asynchronously:

if (window.sourcetrack) {
  window.sourcetrack.conversion({ type: 'lead' })
}

- Lead or signup: type "lead" or "signup". Send no value.
- Purchase: type "purchase", with order_id set to the real order or payment id, value set to the real amount, and currency set to its three-letter code. Never invent or estimate a value.
- Do not put an email address, name, phone number or any other personal data in the call.
- Do not use any server API token or secret key here, and do not ask me for one. The browser call needs no key beyond the site key already in the script tag.

After the builder finishes

  1. Publish the site, then open it on the domain registered in SourceTrack. A preview or development URL is a different host.
  2. Open your browser's Developer Tools, choose Network, and filter by track. Reload: a POST /api/track request should complete.
  3. Check the Event Debugger on the SourceTrack Setup page.

Conversions and revenue: what counts

  • A browser conversion records that something happened. It does not prove a payment: anyone can read the public site key from the page source, so a value sent from the browser is not treated as confirmed revenue.
  • On a site with Stripe or Shopify connected, a browser conversion that carries a value must also carry order_id (or event_id). It is held until the processor's own webhook confirms it, and the webhook is the money record. Refunds and negative values are rejected from the browser.
  • Lead and signup conversions carry no revenue. Send no value for them.
  • For revenue, connect Stripe or Shopify: https://www.sourcetrack.ai/docs/stripe and https://www.sourcetrack.ai/docs/shopify.

Related: the browser conversion call is documented at https://app.sourcetrack.ai/developers/conversions.