Gravity Forms
Gravity Forms is one of the most popular WordPress form plugins. Because it renders standard <form> and <input> elements in the page DOM, AttributionHub’s standard forms handler detects and populates it automatically — no dedicated handler or plugin is required.
All you need to do is add hidden fields to your form with the correct parameter names. AttributionHub fills them with attribution data whenever a visitor submits the form.
Prerequisites
Before you begin, make sure:
- The AttributionHub tracking script is installed on your site (see Installation)
- You have the Gravity Forms plugin installed and activated in WordPress
- You have access to the WordPress admin panel to edit forms
Step 1: Open Your Form
- In your WordPress admin, go to Forms > All Forms
- Click on the form you want to add attribution tracking to, or create a new form
Step 2: Add Hidden Fields
- In the Gravity Forms editor, locate the Advanced Fields panel on the right side
- Click Hidden to add a new hidden field to your form
- Repeat this step for each attribution field you want to capture
We recommend adding at least the core fields listed below. You can add as many or as few as your reporting needs require.
Step 3: Configure Each Hidden Field
For each hidden field you added:
- Click on the hidden field in the form editor to open its settings
- In the Field Label field, enter a descriptive name (e.g., “Attribution Channel”). This label is only visible in the Gravity Forms admin — it does not affect how AttributionHub matches the field
- Open the Advanced tab within the field settings
- In the Parameter Name field, enter the corresponding AttributionHub field name (e.g.,
ah_lt_channel)
The Parameter Name is what AttributionHub uses to identify and populate the field. It must exactly match one of the supported field names listed below.
Important: Do NOT check the “Allow field to be populated dynamically” option. AttributionHub writes values directly into hidden fields in the DOM. Enabling dynamic population can interfere with this process and may cause fields to be overwritten or left empty.
Step 4: Save and Test
- Save your form after adding and naming all hidden fields
- Visit a page with the form on your site
- Open your browser’s DevTools (F12) and inspect the form’s hidden
<input>elements — you should see attribution values populated - Submit a test entry and confirm the values appear in the Gravity Forms entry details within WordPress admin
For a full testing walkthrough, see Verify It Works.
Recommended Hidden Fields
The table below lists the most commonly used fields for Gravity Forms. For the complete field catalog, see Field Reference.
Core Attribution Fields (Latest Touch)
These fields capture details about the visitor’s most recent traffic source:
| Parameter Name | Description | Example Values |
|---|---|---|
ah_lt_channel | Channel group (latest touch) | Paid Search, Organic Social, Direct |
ah_lt_source | Traffic source name | Google, Facebook, Direct |
ah_lt_medium | Traffic medium | paid, organic, social, email |
ah_lt_campaign | Campaign name | spring_sale, Organic Search |
ah_lt_content | Content classification | Paid Search Ad, Social Post |
ah_lt_term | Search keyword (if available) | running shoes |
ah_lt_landing_url | Landing page URL (no query string) | https://yoursite.com/pricing |
Core Attribution Fields (First Touch)
First-touch fields record the very first traffic source that brought the visitor to your site. These values are locked permanently once set:
| Parameter Name | Description | Example Values |
|---|---|---|
ah_ft_channel | Channel group (first touch) | Paid Search, Organic Social |
ah_ft_source | Traffic source name | Google, Facebook |
ah_ft_medium | Traffic medium | paid, organic, social |
ah_ft_campaign | Campaign name | launch_campaign |
ah_ft_landing_url | Original landing page URL | https://yoursite.com/blog/post |
Global Fields
| Parameter Name | Description | Example Values |
|---|---|---|
ah_visitor_id | Unique visitor ID, persistent across visits | a1b2c3d4-e5f6-7890-abcd-ef1234567890 |
ah_touch_count | Total number of recorded visits | 5 |
For additional fields including latest-non-direct touch (
ah_lnd_*), drill-down fields, raw UTM parameters, and ad click IDs, see the full Field Reference.
Custom Field Mapping
If your form already has fields with different names (for example, from a CRM integration), you can map AttributionHub’s internal fields to your custom names using fieldMapping in the script settings:
<script>
window.attrhub = {
settings: {
fieldMapping: {
"latest.attribution.channelGroup": "lead_channel",
"latest.attribution.source": "lead_source",
"latest.attribution.campaign": "campaign_name",
},
},
};
</script>With this configuration, AttributionHub will populate fields named lead_channel, lead_source, and campaign_name instead of the defaults. See Configuration for the full mapping reference.
Tips
- Multiple forms on one page — AttributionHub detects and populates all forms on the page. Each form gets its own hidden fields populated independently.
- Multi-page forms — If your Gravity Forms form spans multiple pages, add hidden fields to the first page so they are populated as soon as the form loads.
- Conditional logic — Hidden fields work with Gravity Forms conditional logic. You can show or hide visible fields based on attribution values if needed.
- Gravity Forms confirmations — Attribution values are included in the form entry data. You can reference them in Gravity Forms confirmation messages, notifications, or feed add-ons (e.g., CRM integrations).
- Pre-existing entries — AttributionHub only populates fields at the time of submission. Existing form entries will not be retroactively updated.
Troubleshooting
Hidden fields are empty in form entries
- Verify the AttributionHub script is loaded on the page — check for network requests to the AttributionHub script in DevTools
- Confirm the Parameter Name on each hidden field exactly matches a supported field name (names are case-sensitive)
- Make sure “Allow field to be populated dynamically” is not checked
- Enable logging (
enableLogging: truein settings) and check the browser Console for population messages
Fields show “[object Object]” or unexpected values
This usually means the Parameter Name does not match a valid field name. Double-check the spelling and casing against the Field Reference.
Form loads after the script runs
Gravity Forms typically renders inline, so this is rare. If your form loads via AJAX or a modal, AttributionHub’s MutationObserver and retry mechanism should catch it. If not, check the Form Integrations troubleshooting guide for additional steps.