Skip to Content

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

  1. In your WordPress admin, go to Forms > All Forms
  2. Click on the form you want to add attribution tracking to, or create a new form

Step 2: Add Hidden Fields

  1. In the Gravity Forms editor, locate the Advanced Fields panel on the right side
  2. Click Hidden to add a new hidden field to your form
  3. 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:

  1. Click on the hidden field in the form editor to open its settings
  2. 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
  3. Open the Advanced tab within the field settings
  4. 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

  1. Save your form after adding and naming all hidden fields
  2. Visit a page with the form on your site
  3. Open your browser’s DevTools (F12) and inspect the form’s hidden <input> elements — you should see attribution values populated
  4. 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.

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 NameDescriptionExample Values
ah_lt_channelChannel group (latest touch)Paid Search, Organic Social, Direct
ah_lt_sourceTraffic source nameGoogle, Facebook, Direct
ah_lt_mediumTraffic mediumpaid, organic, social, email
ah_lt_campaignCampaign namespring_sale, Organic Search
ah_lt_contentContent classificationPaid Search Ad, Social Post
ah_lt_termSearch keyword (if available)running shoes
ah_lt_landing_urlLanding 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 NameDescriptionExample Values
ah_ft_channelChannel group (first touch)Paid Search, Organic Social
ah_ft_sourceTraffic source nameGoogle, Facebook
ah_ft_mediumTraffic mediumpaid, organic, social
ah_ft_campaignCampaign namelaunch_campaign
ah_ft_landing_urlOriginal landing page URLhttps://yoursite.com/blog/post

Global Fields

Parameter NameDescriptionExample Values
ah_visitor_idUnique visitor ID, persistent across visitsa1b2c3d4-e5f6-7890-abcd-ef1234567890
ah_touch_countTotal number of recorded visits5

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

  1. Verify the AttributionHub script is loaded on the page — check for network requests to the AttributionHub script in DevTools
  2. Confirm the Parameter Name on each hidden field exactly matches a supported field name (names are case-sensitive)
  3. Make sure “Allow field to be populated dynamically” is not checked
  4. Enable logging (enableLogging: true in 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.