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>
Add the tracker once in your root layout:
import Script from "next/script";
const HRD_URL = "https://analytics.yourdomain.com";
const HRD_TRACKER_SRC = HRD_URL + "/tracker.js";
const HRD_TENANT_ID = "your-tenant-id";
const HRD_SOURCE_ID = "your-source-id";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script
id="hrd-tracker"
strategy="afterInteractive"
src={HRD_TRACKER_SRC}
data-tenant-id={HRD_TENANT_ID}
data-source-id={HRD_SOURCE_ID}
/>
</body>
</html>
);
}
Add the script to the <head> of your React app’s HTML template.
<script
async
src="https://analytics.yourdomain.com/tracker.js"
data-tenant-id="your-tenant-id"
data-source-id="your-source-id">
</script>
Add the script to the <head> of your Vue app’s HTML template.
<script
async
src="https://analytics.yourdomain.com/tracker.js"
data-tenant-id="your-tenant-id"
data-source-id="your-source-id">
</script>
Add the script to the <head> of the root index.html.
<script
async
src="https://analytics.yourdomain.com/tracker.js"
data-tenant-id="your-tenant-id"
data-source-id="your-source-id">
</script>
The Hardal Shopify app installs its own web pixel. Follow these steps in Shopify Admin.
- Choose Shopify, then Install on Shopify to open the Hardal app listing.
- In Shopify Admin, open Apps → Hardal, choose Configure Analytics, and select Hardal AI. If you see Signal URL and Signal ID, the Legacy option is selected.
- Copy Tenant ID, Source ID, and the collection hostname from Hardal Setup into Tenant ID, Source ID, and Hardal AI endpoint. Select Save and Start Tracking.
- Open a storefront page. In the Current Dashboard, open Engagement → Events for the same tenant and source and look for
page_view. Opening a product page can also sendview_item.
Paste this into a Custom HTML tag in your web container. Set the tag to fire on all pages.
<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
| Attribute | What it does |
|---|---|
src | The tracker script, served from your source's first-party URL. |
data-host-url | Optional. 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-id | The Tenant ID shown for this installation in Setup. |
data-source-id | The Source ID shown for this installation in Setup. |
data-auto-track | Optional. 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-spa | Optional. Defaults to true, which tracks History API and hash route changes. Set it to false to disable it. |
data-consent | Optional. 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:
| Event | When it is recorded |
|---|---|
page_view | When the page first loads. |
scroll | Once on the first page scroll in each page view. |
scroll_depth | Once for each reached milestone: 25%, 50%, 75%, 90%, and 100%. The milestone is stored in percent. |
outbound_click | Each 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.
Standard Events
Use consistent names and parameters for commerce and lead events.
Custom Events
Define an event name and fields for interactions specific to your product.
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.jsloads from the collection URL in Setup.- On a normal page load, the tracker sends a
POSTto/collect/. Check the202response fordata.acceptedwhen the browser exposes the response body. - The request uses
text/plain, which avoids a JSON preflight. - The body contains
tenantId, ananonymousSessionId, and aneventsarray. The automatic page view hastype: "page_view"andeventName: "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.