Skip to docs navigation
On this page

Install the script

Add one snippet to your site. SourceTrack then records visits and where they came from.

Paste the snippet into your site

You need: your snippet, shown in the app under Setup & Health. Your site key is already filled in. In the examples below, put your own key in place of YOUR_SITE_KEY.

Copy your snippet from Setup & Health. It is in the Install the script step, with your site key already filled in.

Script tag

Paste it inside the <head> of your site, in the layout your pages share. It looks like this:

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

Google Tag Manager

In your Google Tag Manager container, create a Custom HTML tag with this code. Trigger it on Initialization - All Pages, then choose Submit → Publish. Google Tag Manager guide

HTML
<!-- Paste this inside a Custom HTML Tag in GTM -->
<script>
  (function() {
    if (document.querySelector('script[data-site-key]')) return;
    var script = document.createElement('script');
    script.src = 'https://api.srctk.com/tracker.min.js';
    script.setAttribute('data-site-key', 'YOUR_SITE_KEY');
    script.async = true;
    document.head.appendChild(script);
  })();
</script>

WordPress

Paste the snippet into the Header section of a header plugin such as WPCode, or just before </head> in your theme's header.php. Then clear your site cache. WordPress guide

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

Shopify

In your Shopify Admin, go to Online Store → Themes → Edit Code. Open layout/theme.liquid and paste the snippet just before </head>. The Shopify guide also covers order revenue.

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

Webflow

Open your site settings and the Custom Code tab. Paste the snippet into Head Code, save, then Publish. Webflow guide

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

Framer

Open Project Settings → Custom Code and paste the snippet into the Start of <head> field. Save, then Publish. Framer guide

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

Next.js

In app/layout.tsx (or .js), add the script inside <body>. For the Pages Router, see the Next.js guide.

JSXapp/layout.tsx
import Script from 'next/script'

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          src="https://api.srctk.com/tracker.min.js"
          data-site-key="YOUR_SITE_KEY"
          strategy="afterInteractive"
        />
      </body>
    </html>
  )
}

React

Paste the snippet inside <head> of index.html at the project root (Vite) or public/index.html (Create React App). Then build and deploy. React guide

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

Angular

An Angular app has one HTML page. Paste the snippet inside <head> of src/index.html, then build and deploy. Visits from your local dev server show as test traffic.

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

Vue

Paste the snippet inside <head> of index.html at the project root, then build and deploy. Page changes are tracked for you.

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

Laravel

Paste the snippet inside <head> of your base Blade layout, usually resources/views/layouts/app.blade.php. If you cache compiled views, run php artisan view:clear. Laravel guide

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

Express

For a server-rendered Express app, add the snippet to the <head> of the template your pages render (EJS, Pug or Handlebars). For a single-page app served by Express, put it in index.html.

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

Using a site builder or store? Find your platform in the platform guides.

NoteUsing a custom tracking domain? Your snippet loads from your own subdomain instead. Copy the snippet from Setup & Health, not from this page.

Building with Lovable, Bolt, Replit or v0? Use the copy-paste prompts instead.

Check that it works

  1. Open your live website in a new tab.
  2. In Setup & Health, open Check tracking coverage.
  3. Look at the Tracking Doctor badge. It reads Tracking: Healthy when events arrive from your registered domain.
  4. Look for your visit in the Live Events Feed.

For proof from a real visit, press Open test page under Verify a live pageview. Tracking Doctor confirms when that visit arrives.

What the Tracking Doctor badge means

  • Healthy: recent events are arriving from your registered domain.
  • Waiting for first event: no visit has arrived yet.
  • Wrong domain: events come from a different address than the one you registered.
  • Test traffic detected: events come from a local or test copy of your site.
  • No recent traffic: no events for over a day, on a site with few visits.
  • Needs attention: something is wrong. Read the message under the badge.
Warning

What Tracking Doctor does not prove

  • It does not prove that every page has the script.
  • It does not prove that your conversions and revenue are set up.
  • It does not check how accurate your attribution is.

Not seeing data? See Troubleshooting.

Key terms
  • Snippet — the line of code you paste into your site.
  • Site key — the ID inside your snippet. It tells SourceTrack which site a visit belongs to.
  • Pageview — one visit to one page of your site.
What the script records
  • Pageviews, including page changes on single-page sites.
  • Campaign tags in your links, called UTM parameters.
  • The click IDs that ad platforms add to your links.
  • The site that sent the visitor.
  • The browser, operating system and country of the visitor.

Visits from browsers that send Do Not Track or Global Privacy Control are not tracked.

Common problems
  • The wrong site key, or YOUR_SITE_KEY still in the snippet. Copy your snippet again from Setup & Health and replace the old one.
  • An ad blocker is on. Pause it, or test in a clean browser window.
  • You are not sure the snippet is on your site. Press Check my homepage in Tracking Doctor. It reports a missing snippet, a wrong key or a blocked script.

Next step

Set up conversions so sign-ups, leads and sales trace back to a source. Read the Browser Conversions guide.

Still stuck?

Email support@sourcetrack.ai with your site and what you have tried.

Start 28-day free trial
  • Google Ads
  • Meta
  • LinkedIn
  • Microsoft Ads
  • TikTok
  • Stripe
  • Shopify
  • HubSpot
  • GA4
  • Search Console
  • WooCommerce
  • Webflow
  • WordPress
  • Typeform
  • Calendly
  • Intercom
  • Zapier
Works with