Web tracking collects behavioral signals from digital properties. It captures what a visitor is doing in the moment, making it one of the most common ways to build audiences and trigger journeys based on intent.
The base script connects your website to the platform for event collection and tag management. This guide covers how to set up the script, classify pages, pass context, and verify that events are arriving correctly.
Web tracking solves 3 practical needs that are hard to replace with backend data (such as profile data or stored data) alone:
Measuring what drives demand: Understanding which channels, campaigns, and messages lead to site engagement and conversions.
Building retargeting and suppression inputs: Advertising platforms rely on event signals, such as "viewed product page" or "started checkout", to build audiences. Without these signals, you're unable to target different audiences with different creatives, and the acquisition spend is harder to control.
Triggering experiences based on intent: Many personalization and lifecycle use cases start from website behavior because it reflects intent before a person is known.
How web tracking works
The web tracking pattern is consistent across implementations:
A small snippet runs in the browser.
The snippet records key interactions as events.
The snippet forwards those events to analytics, advertising, and activation tools.
Web events are tied to an anonymous visitor until an identifier becomes available. If the visitor later logs in or submits an identifier, your setup can connect the activity to a known profile.
Most web events include:
Event name and timestamp
Page or screen context
Browser or device identifier
Product or content identifiers, when relevant
Acquisition context, such as referrer or UTM parameters
Customer identifier when available after login or form submission
Common concepts:
Pixels are tracking tags that send events to a specific vendor (for example, Meta Pixel). They measure conversions, build retargeting pools, and train ad delivery algorithms.
Tag managers are tools used for deploying and managing website tags without changing code. Google Tag Manager is the most common example. They help marketing teams move faster, but can lead to uncontrolled tag growth if governance is weak.
Recommended starter events
At a minimum, track these events to support common activation use cases:
Event | When to fire | Key properties |
|---|---|---|
| Every page load | Page structure, URL |
| Product detail page | Product ID, category |
| Item added to cart | Product ID, quantity, value |
| Checkout initiated | Cart value |
| Order confirmed | Order ID, order value |
| User authenticates | Customer ID (hashed if needed) |
Example: anonymous visitor retargeting
A retailer wants to retarget visitors who viewed a product but did not buy:
The site tracks product-view events with a product ID and timestamp.
The visitor remains anonymous, but the site still records their behavior.
You have defined an audience as "viewed product in the last 3 days and no purchase".
The platform pushes that audience to an ad platform for retargeting.
If the visitor later becomes known, the same behavior can support personalized journeys.
Effectiveness depends on what identifiers are available and how well the destination can match them.
Word of caution about browser scripts
Many digital teams have become stricter about what runs in the browser because browser scripts may cause various types of issues:
Too many tags can slow down pages and increase bounce rates, indicating that scripts are causing performance issues.
Ad blockers, tracking prevention, and script failures reduce data completeness, making browser scripts a reliability risk.
Browser scripts can pose risks from a privacy and governance perspective. Uncontrolled tags can create compliance issues if your setup doesn't consistently handle consent.
The possible issues with browser scripts don't mean that browser tracking is obsolete. It means that teams often need a more controlled approach, often combined with server-side collection for critical signals.
Before you begin
Make sure that you have the following details needed to set up web tracking:
Access to edit your website's HTML or tag manager configuration
The base script snippet is provided during platform onboarding.
You and your team have agreed on a page structure naming convention.
You know which environments you need (test and production).
Instructions
Step 1: Add the base script to your site
Add the script snippet to all pages where you want to collect data. Place the script in the <head> section for consistent loading.
Best practices:
Use a single shared include in the header section to prevent the snippet from being added twice.
Include a server-side switch to quickly disable the script if needed.
Use a server-side variable for the script version to simplify upgrades.
Step 2: Set the environment (optional)
Set the environment to control whether you're in test or production mode. If not set, the system defaults to the production environment.
Use test during initial setup and QA. Switch to production when going live.
_st('setEnvironment', 'test');Step 3: Set the page structure
Page structure classifies the current page using a predictable hierarchy. This controls which tags load and makes rules easier to maintain.
_st('setPageStructure', 'product|details');Follow these patterns:
Keep the first level broad:
homepage,category,product,checkout,account.Add detail only when it changes what should load (for example,
checkout|paymentvs.checkout|confirmation).Use the same names across markets and brands.
You can set a default fallback for pages that are hard to classify:
_st('setDefaultPageStructure', 'generic|content');Step 4: Add tag properties
Tag properties contain additional context for the current pageview. Use them for locale, site section, or other non-sensitive page context.
_st('addTagProperties', { country: 'fi', language: 'en' });Don't pass any personally identifiable information to the service, such as:
Email addresses, phone numbers, or direct identifiers
Sensitive customer attributes
Anything not needed to run tagging rules
For single-page applications, reset the context before setting new properties:
_st('resetTags');Step 5: Trigger tag loading
After setting the environment, page structure, and properties, trigger tag loading:
_st('loadTags');Complete example for a product details page:
_st('setEnvironment', 'test');
_st('setPageStructure', 'product|details');
_st('addTagProperties', { country: 'fi', language: 'sv' });
_st('loadTags');Verify the setup works
After the setup is complete, confirm that events are arriving:
Open your browser's developer tools and check the Network tab for requests to the platform endpoint.
Verify that page structure and properties appear correctly in the request payload.
If not, you may have inconsistent page naming. To fix this, compare the values across pages and teams.
In the Data activation platform, check that events appear for test profiles.
If the events aren't appearing, it's likely the script isn't loading. Check for script errors in the browser's developer tools console.
If the properties are missing, check the call order in your setup and verify that the properties are set before loadTags.
If you see duplicate events, the script may have loaded twice. Check that the script loads just once.
If the events are in the wrong environment, check that you have set the correct environment and that setEnvironment is called before loadTags.
Confirm that audiences based on these events start populating as expected.
See How to test and roll out web tracking.
Common pitfalls
Your data activation is only as reliable as your data is. The following issues are common in web tracking, so be on the lookout for these:
Key events are missing (for example, purchase confirmation), leading to stale retargeting.
IDs are inconsistent between web events and backend systems.
Your team adds too many tags without governance, hurting performance.
Your setup expects cross-device continuity without deterministic identifiers. Without merged profiles, you won’t be able to identify users across sessions or across devices, which hampers your ability to target and personalize