Skip to content

Installation

The Attri tracking script (a.js) is a lightweight JavaScript snippet you add to your website. We’ve spent a lot of time making sure it stays small and fast. It captures pageview and conversion events, connecting them back to the shortlinks that drove the traffic.

Add this snippet to the <head> of every page on your website:

<script defer data-wid="YOUR_WORKSPACE_ID" src="https://cdn.attri.io/a.js"></script>

Replace YOUR_WORKSPACE_ID with your workspace’s unique identifier. You can find it under Settings > General in the app.

When the script loads, it:

  1. Reads UTM parameters from the current page URL
  2. Stores them in a first-party cookie for the session
  3. Sends a pageview event to Attri’s analytics pipeline
  4. Watches for conversion events (if configured)

The script is under 5KB gzipped and loads asynchronously with defer, so it won’t block your page rendering. That’s by design.

After installing the script, visit your website and check the Dashboard in Attri. You should see pageview events appearing within a few seconds (we typically see them show up in under two seconds in our testing).

You can also open your browser’s developer tools and check the Network tab for requests to cdn.attri.io.

Add the script to your root layout:

app/layout.tsx
export default function RootLayout({ children }) {
return (
<html>
<head>
<script defer data-wid="YOUR_WORKSPACE_ID" src="https://cdn.attri.io/a.js"></script>
</head>
<body>{children}</body>
</html>
)
}

Add the script in Settings > Header Scripts, or use a plugin like Insert Headers and Footers.

Go to Online Store > Themes > Edit code > theme.liquid and paste the script tag inside the <head> section. It takes about thirty seconds.