LearnWeb Setup

Web Setup

Install the Hardal tracker script on your website to collect page views, scroll activity, and outbound clicks through your first-party URL.

Before you install

Open Manage → Setup in the Dashboard and click Setup on your source. Connect its tracking domain and wait for Tracking domain to show Connected and "Your tracking domain is ready."

Under Installation → Tracker, select your platform and copy the generated snippet. Add the tracker once through your chosen installation method.

Install the script

Put the script inside your HTML <head> tag:

<script
  async
  src="https://analytics.yourdomain.com/tracker.js"
  data-tenant-id="your-tenant-id"
  data-source-id="your-source-id">
</script>

Replace the example hostname and IDs with the generated values from Setup. If the hostname changes, copy the updated snippet and redeploy your installation.

Script attributes

AttributeWhat it does
srcThe tracker script, served from your source's first-party URL.
data-host-urlOptional. Defaults to the origin of src, so events are sent to the same URL the script is served from. Set it only to send events to a different URL.
data-tenant-idThe Tenant ID shown for this installation in Setup.
data-source-idThe Source ID shown for this installation in Setup.
data-auto-trackOptional. Defaults to true, which collects the initial page view, scroll activity, and outbound link tracking. Set it to false to disable these; SPA page views are controlled separately by data-spa.
data-spaOptional. Defaults to true, which tracks History API and hash route changes. Set it to false to disable it.
data-consentOptional. Set granted or denied before loading the script if you already know the visitor's saved choice.

Only src, data-tenant-id, and data-source-id are required.

Privacy by default

The base tracker can collect anonymous first-party analytics without attaching a known user identity. Your consent and disclosure requirements still depend on your implementation, destinations, and applicable law.

When a visitor grants consent, send the consent state so Hardal can link activity according to your configuration.

Consent Signals

How to send a granted or denied signal, and what each one changes.

What gets tracked automatically

Automatic collection requires the Hardal web tracker installed on your website with automatic tracking enabled. An API-only integration does not automatically track page views, scrolls, scroll depth, or outbound clicks; your implementation must send these events explicitly.

With data-auto-track="true" (the default), the script collects:

EventWhen it is recorded
page_viewWhen the page first loads.
scrollOnce on the first page scroll in each page view.
scroll_depthOnce for each reached milestone: 25%, 50%, 75%, 90%, and 100%. The milestone is stored in percent.
outbound_clickEach activation of an external HTTP(S) link. Includes the destination URL (linkUrl) and hostname (linkDomain).

Scroll milestones reset with each new tracked page view. Scrolling inside a nested container is not measured as page scrolling. Pages without a scrollable area produce no depth milestones.

Links within the current site's domain and its subdomains are internal. For other domains that belong to your journey, configure Internal domains for the source. Internal clicks are excluded from stored outbound events. Links such as mailto: and tel: are not tracked.

With SPA tracking enabled (the default), it also sends page_view after client-side route changes, including history and hash changes. It skips duplicate page views for the same URL.

Send form submissions, purchases, and other business events explicitly. Avoid adding separate tags for the same automatically collected interactions, which can duplicate events.

Send a page view manually

To send your own page views, set data-auto-track="false" and data-spa="false" on the tracker script to turn off built-in page views for initial loads and route changes. This also turns off automatic scroll and outbound click tracking.

After the tracker loads, call this once per page view. On a single-page app, call it after the browser URL has updated.

hrd.track("page_view");

Send additional events

Send purchases, leads, and other business events explicitly. For events confirmed on your server, use the API & Server-side setup. Use the event guides below to choose consistent names and parameters.

Coordinate business events with tracker loading

Run hrd.track() after tracker.js finishes loading. In Google Tag Manager, run your Custom HTML event tag after the tracker is ready. Starting the installation tag only begins the script download.

Verify your installation by visiting the site outside GTM Preview and checking Engagement → Events.

Content Security Policy

If your site uses Content Security Policy, add your collection origin to the existing script-src and connect-src directives. For example:

script-src 'self' https://analytics.yourdomain.com;
connect-src 'self' https://analytics.yourdomain.com;

Verify it works

Open your site and check the browser Network panel:

  • tracker.js loads from the collection URL in Setup.
  • On a normal page load, the tracker sends a POST to /collect/. Check the 202 response for data.accepted when the browser exposes the response body.
  • The request uses text/plain, which avoids a JSON preflight.
  • The body contains tenantId, an anonymousSessionId, and an events array. The automatic page view has type: "page_view" and eventName: "page_view".
  • The event payload uses the Source ID shown in Setup.

Scroll the page and activate an external link, then check Engagement → Events for scroll, scroll_depth, and outbound_click. A collection request can contain internal link candidates that are filtered before storage; check the Events report to confirm stored outbound clicks.

In Setup Status, use Check Web Analytics data to confirm browser activity. The Tracking domain and AI Visibility rows show their own statuses.

Campaign setup

Follow Track Campaigns with UTM Parameters to verify traffic context, then Monitor a Campaign Launch to check incoming activity and outcomes.

Verify Your Setup

Use the source Setup page to check DNS, browser events, and AI Visibility verification separately.