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.
Adding the script
Section titled “Adding the script”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.
How it works
Section titled “How it works”When the script loads, it:
- Reads UTM parameters from the current page URL
- Stores them in a first-party cookie for the session
- Sends a pageview event to Attri’s analytics pipeline
- 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.
Verification
Section titled “Verification”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.
Framework-specific guides
Section titled “Framework-specific guides”Next.js
Section titled “Next.js”Add the script to your root layout:
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> )}WordPress
Section titled “WordPress”Add the script in Settings > Header Scripts, or use a plugin like Insert Headers and Footers.
Shopify
Section titled “Shopify”Go to Online Store > Themes > Edit code > theme.liquid and paste the script tag inside the <head> section. It takes about thirty seconds.
Next steps
Section titled “Next steps”- Pageview Tracking — Understand what pageview data is captured
- Conversion Tracking — Track form submissions, purchases, and other conversions