Installing ServerTrack on Your Website

Last updated: January 30, 2026 • 5 min read

Step-by-step instructions for adding the ServerTrack tracking script to your website. Works with any platform including custom HTML sites.

Introduction

Installing ServerTrack on your website is a simple process that involves adding a small JavaScript snippet to your site. This script enables server-side tracking and automatically sends conversion events to your connected marketing platforms (Facebook, TikTok, GA4).

Getting Your Tracking Script

Before installing, you need to get your tracking script code from your ServerTrack dashboard:

  • Log in to your ServerTrack dashboard
  • Select your Server Deck
  • Navigate to the "Installation" or "Edit Configuration" section
  • You'll see a code block with your personalized tracking script
  • Click the "Copy" button to copy the entire script

Your script will look like this:

<script>
(function(w, d, u, k) {
    w.ServerTrack = w.ServerTrack || {};
    w.serverTrackQueue = [];
    w.st = function() { w.serverTrackQueue.push(arguments); };
    var s = d.createElement('script'); s.async = 1; 
    s.src = u + '?key=' + k; 
    var h = d.getElementsByTagName('script')[0]; h.parentNode.insertBefore(s, h);
})(window, document, 'https://data.yoursite.com/tracker.js', 'YOUR_AUTH_KEY');
</script>

Important: Make sure you've already set up and verified your custom domain before installing the script. The script URL must point to your verified tracking domain (e.g., https://data.yoursite.com/tracker.js).

Where to Place the Script

The best practice is to place the ServerTrack script in the <head> section of your website, ideally as early as possible. This ensures the tracking library loads quickly and is available when you need to track events.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Your Website</title>
    
    <!-- ServerTrack Tracking Script -->
    <script>
    (function(w, d, u, k) {
        w.ServerTrack = w.ServerTrack || {};
        w.serverTrackQueue = [];
        w.st = function() { w.serverTrackQueue.push(arguments); };
        var s = d.createElement('script'); s.async = 1; 
        s.src = u + '?key=' + k; 
        var h = d.getElementsByTagName('script')[0]; h.parentNode.insertBefore(s, h);
    })(window, document, 'https://data.yoursite.com/tracker.js', 'YOUR_AUTH_KEY');
    </script>
    
</head>
<body>
    <!-- Your website content -->
</body>
</html>

Alternative: Before </body> Tag

If you prefer to load tracking scripts at the end of the page (to prioritize content loading), you can place it just before the closing </body> tag. However, this may cause a slight delay in event tracking.

Installation by Platform Type

Plain HTML Website

  • Open your website's main HTML file (usually index.html)
  • Locate the <head> section
  • Paste your ServerTrack script code
  • Save the file
  • Upload to your web server
  • Verify installation (see below)

WordPress Website

There are several ways to add the script to WordPress:

Method 1: Using our Plugin (Recommended)

  • Install our Plugin → Download Plugin
  • Go to Settings → ServerTrack
  • Paste our Authentication Key
  • Save changes

Method 2: Theme Editor

  • Go to Appearance → Theme Editor
  • Select "Theme Header" (header.php)
  • Paste the script before the closing </head> tag
  • Update file

Note: If you're using a child theme, always edit the child theme files, not the parent theme. Changes to parent themes will be lost when the theme updates.

Shopify Store

  • Log in to your Shopify admin
  • Go to Online Store → Themes
  • Click "Actions" → "Edit Code"
  • Open theme.liquid
  • Find the </head> tag
  • Paste your ServerTrack script just before it
  • Save

Custom CMS or Framework

For custom CMS or frameworks (React, Vue, Next.js, etc.), you'll need to:

  • Identify where global scripts are loaded (usually a layout component or _app.js in Next.js)
  • Add the script to that location
  • Ensure it loads on all pages where you want tracking

Verifying Installation

After installing the script, verify it's working correctly:

Method 1: Browser Console

  • Open your website in a browser
  • Open Developer Tools (F12 or Right-click → Inspect)
  • Go to the Console tab
  • Type: window.st and press Enter
  • You should see a function definition, not "undefined"
  • Type: window.ServerTrack and press Enter
  • You should see an object, not "undefined"

Method 2: Network Tab

  • Open Developer Tools (F12)
  • Go to the Network tab
  • Reload the page
  • Filter by "tracker.js" or "JS"
  • You should see a request to https://data.yoursite.com/tracker.js?key=YOUR_KEY
  • The request should return status 200 (success)

Method 3: ServerTrack Dashboard

  • Go to your ServerTrack dashboard
  • Navigate to your Server Deck
  • Go to the "Event Logs" or "Live Debugger" section
  • Trigger a test event on your website (if you've implemented event tracking)
  • You should see the event appear in the logs within a few seconds

Common Installation Issues

Script Not Loading

  • Verify your domain is correctly verified in ServerTrack
  • Check that the script URL matches your verified domain
  • Ensure there are no JavaScript errors blocking script execution
  • Check browser console for error messages

Events Not Being Tracked

  • Verify the script is installed correctly (use verification methods above)
  • Check that you're calling st('track', ...) after the script loads
  • Ensure your Server Deck status is "Active" (not Paused)
  • Check event logs in ServerTrack dashboard for error messages

Next Steps

Once your script is installed and verified:

  • Configure your platform integrations (Facebook, TikTok, GA4) in the ServerTrack dashboard
  • Implement event tracking on your website (Purchase, AddToCart, etc.)
  • Test events using the Live Event Debugger
  • Monitor your event logs to ensure everything is working correctly

For more detailed guides, see our Standard Events Reference Guide.

Was this article helpful?

Please log in to provide feedback on this article.