Skip to Content
Configuration

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

SettingTypeDefaultDescription
storageNamestring'attrhub'The localStorage key used to persist attribution data
enableLoggingbooleanfalseEnable info-level logging to the browser console
enableDebugLoggingbooleanfalseEnable verbose debug logging
customFieldsstring[][]Custom URL parameters to capture as attribution fields
fieldMappingobject(130+ defaults)Override form field name mapping
formSelectorsstring[][]Additional CSS selectors for form discovery (merged with defaults)
fieldRulesobjectundefinedCustom 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_tier
  • ah_lt_custom_product_tier
  • ah_lnd_custom_product_tier
  • ah_ft_custom_referral_code
  • ah_lt_custom_referral_code
  • ah_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 PrefixDescription
first.First touch fields
latest.Latest touch fields
latestNonDirect.Latest non-direct touch fields

Common sub-paths:

Sub-pathDescription
.attribution.channelGroupChannel group
.attribution.sourceSource name
.attribution.sourceDomainSource domain
.attribution.sourcePlatformSource platform
.attribution.campaignCampaign
.attribution.mediumMedium
.attribution.mediumDetailMedium detail
.attribution.contentContent label
.attribution.contentDetailContent detail
.attribution.termSearch term
.attribution.isPaidPaid flag
.drillDown.channelDrill-down channel
.drillDown.drillDown1Drill-down level 1
.drillDown.drillDown2Drill-down level 2
.drillDown.drillDown3Drill-down level 3
.timestampTouch timestamp
.landingUrlLanding URL
.referrerUrlReferrer 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>