Installation
Detailed instructions for adding AttributionHub to your website.
Basic Installation
Add the script tag to the <head> of every page on your site:
<script
src="https://cdn.attributionhub.com/attribution.js?id=YOUR_LICENSE_KEY"
async
defer
></script>The async defer attributes ensure the script loads without blocking page rendering.
Installation with Custom Settings
To customize behavior, define settings before loading the script:
<script>
window.attrhub = {
settings: {
enableLogging: false,
customFields: ["product_tier", "referral_code"],
},
};
</script>
<script
src="https://cdn.attributionhub.com/attribution.js?id=YOUR_LICENSE_KEY"
async
defer
></script>See Configuration for all available settings.
Platform-Specific Guides
WordPress
Option 1: Theme header
Add the script to your theme’s header.php file, inside the <head> tag.
Option 2: Plugin Use a plugin like “WPCode” or “Insert Headers and Footers” to add the script to your site header without editing theme files.
Option 3: functions.php
function add_attributionhub_script() {
echo '<script src="https://cdn.attributionhub.com/attribution.js?id=YOUR_LICENSE_KEY" async defer></script>';
}
add_action('wp_head', 'add_attributionhub_script');Next.js
// app/layout.tsx
import Script from "next/script";
export default function RootLayout({ children }) {
return (
<html>
<head>
<Script
src="https://cdn.attributionhub.com/attribution.js?id=YOUR_LICENSE_KEY"
strategy="afterInteractive"
/>
</head>
<body>{children}</body>
</html>
);
}Webflow
- Go to Project Settings > Custom Code
- Paste the script tag in the Head Code section
- Click Save Changes
- Publish your site
Shopify
- Go to Online Store > Themes > Edit Code
- Open
theme.liquid - Paste the script tag before
</head> - Save
Google Tag Manager
- Create a new Custom HTML tag
- Paste the script tag
- Set trigger to All Pages
- Submit and publish
<script
src="https://cdn.attributionhub.com/attribution.js?id=YOUR_LICENSE_KEY"
async
defer
></script>Squarespace
- Go to Settings > Advanced > Code Injection
- Paste the script tag in the Header section
- Save
Wix
- Go to Settings > Custom Code
- Click Add Custom Code
- Paste the script tag
- Set placement to Head and apply to All Pages
Verifying Installation
After adding the script, verify it’s working:
- Open your site in an incognito browser window
- Open DevTools (F12) > Console
- Type
localStorage.getItem('attrhub')and press Enter - You should see a JSON object with attribution data
If you see null, try navigating to your site with test UTM parameters:
https://yoursite.com/?utm_source=test&utm_medium=cpc&utm_campaign=verificationSelf-Hosted Installation
If you prefer to host the script yourself:
- Download the latest
attribution.jsfrom your AttributionHub dashboard - Host it on your own CDN or server
- Update the
srcattribute in your script tag to point to your hosted version
Note: Self-hosted scripts still perform license validation. You need a valid license key to use AttributionHub.
Troubleshooting
Script not loading
- Check browser DevTools > Network tab for any blocked requests
- Verify your ad blocker isn’t blocking the script
- Ensure the license key is correct
No data in localStorage
- Make sure you’re testing in an incognito window (existing data may interfere)
- Check the Console tab for any error messages
- Verify the script URL is correct and accessible
Forms not populating
- Ensure hidden fields exist in the form DOM before AttributionHub initializes
- Check that field names match (e.g.,
ah_lt_channel,ah_lt_source) - See Form Integrations for platform-specific requirements