Configuration
Customize AttributionHub by defining settings before loading the script.
Basic Configuration
<script>
window.attrhub = {
settings: {
// your settings here
},
};
</script>
<script
src="https://cdn.attributionhub.com/attribution.js?id=YOUR_LICENSE_KEY"
async
defer
></script>Available Settings
| Setting | Type | Default | Description |
|---|---|---|---|
storageName | string | 'attrhub' | The localStorage key used to persist attribution data |
enableLogging | boolean | false | Enable info-level logging to the browser console |
enableDebugLogging | boolean | false | Enable verbose debug logging |
customFields | string[] | [] | Custom URL parameters to capture as attribution fields |
fieldMapping | object | (130+ defaults) | Override form field name mapping |
formSelectors | string[] | [] | Additional CSS selectors for form discovery (merged with defaults) |
fieldRules | object | undefined | Custom channel classification rules (see Custom Rules Engine) |
Storage Name
Change the localStorage key if you need to avoid conflicts with other scripts:
window.attrhub = {
settings: {
storageName: "my_attribution_data",
},
};Logging
Enable logging during development to see what the script is doing:
window.attrhub = {
settings: {
enableLogging: true, // Shows info messages
enableDebugLogging: true, // Shows detailed debug messages
},
};Open the browser Console (F12) to see log output. Disable logging in production.
Custom Fields
Capture additional URL parameters beyond the standard UTMs:
window.attrhub = {
settings: {
customFields: ["product_tier", "referral_code", "ab_test"],
},
};When a visitor arrives with ?product_tier=enterprise&referral_code=ACME123, these values are stored and available as form fields:
ah_ft_custom_product_tierah_lt_custom_product_tierah_lnd_custom_product_tierah_ft_custom_referral_codeah_lt_custom_referral_codeah_lnd_custom_referral_code
Field Mapping
Override how internal attribution fields map to form field names. Use this when your CRM or form platform uses different field names:
window.attrhub = {
settings: {
fieldMapping: {
"latest.attribution.channelGroup": "lead_source_channel",
"latest.attribution.source": "lead_source_name",
"latest.attribution.campaign": "marketing_campaign",
"first.attribution.channelGroup": "original_channel",
"first.attribution.source": "original_source",
},
},
};Field Path Reference
The field mapping uses dot-notation paths:
| Path Prefix | Description |
|---|---|
first. | First touch fields |
latest. | Latest touch fields |
latestNonDirect. | Latest non-direct touch fields |
Common sub-paths:
| Sub-path | Description |
|---|---|
.attribution.channelGroup | Channel group |
.attribution.source | Source name |
.attribution.sourceDomain | Source domain |
.attribution.sourcePlatform | Source platform |
.attribution.campaign | Campaign |
.attribution.medium | Medium |
.attribution.mediumDetail | Medium detail |
.attribution.content | Content label |
.attribution.contentDetail | Content detail |
.attribution.term | Search term |
.attribution.isPaid | Paid flag |
.drillDown.channel | Drill-down channel |
.drillDown.drillDown1 | Drill-down level 1 |
.drillDown.drillDown2 | Drill-down level 2 |
.drillDown.drillDown3 | Drill-down level 3 |
.timestamp | Touch timestamp |
.landingUrl | Landing URL |
.referrerUrl | Referrer URL |
Form Selectors
Extend the default CSS selectors used to discover forms on the page. The defaults are form, .form, [role="form"], and [data-form]. Your custom selectors are merged with these defaults and deduplicated.
This is useful when a form platform uses non-standard containers that the default selectors do not match:
window.attrhub = {
settings: {
formSelectors: [
".gform_wrapper form",
".mc-embedded-subscribe-form",
'form[action*="pipedrive.com"]',
".payload-form",
],
},
};Platforms that use iframes, SDK APIs, or cross-origin messaging (HubSpot, Marketo, Pardot, ActiveCampaign, Calendly, Typeform, Zoho, Jotform) have dedicated handlers and do not need custom selectors. See Form Integrations for details.
Custom Rules
See the dedicated Custom Rules Engine page for configuration details.
Full Example
<script>
window.attrhub = {
settings: {
storageName: "attrhub",
enableLogging: false,
customFields: ["pricing_plan", "partner_id"],
fieldMapping: {
"latest.attribution.channelGroup": "marketing_channel",
"latest.attribution.source": "marketing_source",
"latest.attribution.campaign": "marketing_campaign",
},
fieldRules: {
mode: "prepend",
rules: [
{
name: "Partner traffic",
conditions: {
field: "utm_source",
operator: "starts_with",
value: "partner_",
},
output: {
channel: "Affiliate",
sourcePlatform: "Partner Program",
isPaid: false,
},
stopProcessing: true,
},
],
},
},
};
</script>
<script
src="https://cdn.attributionhub.com/attribution.js?id=YOUR_LICENSE_KEY"
async
defer
></script>