Skip to Content

Gravity Forms

Gravity Forms is one of the most popular WordPress form plugins. It renders standard <form> and <input> elements in the DOM, which means AttributionHub picks it up automatically — no extra plugin or custom code needed.

The setup is straightforward: add hidden fields to your form with the right names, and AttributionHub takes care of filling them with attribution data on every submission.

Prerequisites

Before you start, make sure you have:

  • The AttributionHub tracking script running on your site (see Installation)
  • Gravity Forms installed and activated in WordPress
  • Access to the WordPress admin to edit forms

Step 1: Open Your Form

  1. In your WordPress admin, head to Forms > Forms
  2. Click the form you want to set up, or go ahead and create a new one

Gravity Forms list in WordPress admin

Step 2: Add Hidden Fields

  1. In the form editor, find the Add Fields panel on the right
  2. Click Hidden to drop a new hidden field into your form
  3. Do this for each attribution field you want to capture

The Hidden field type in the Add Fields panel

We recommend adding at least the core fields listed further down this page. Pick whichever ones matter for your reporting — you don’t have to add them all.

Step 3: Configure Each Hidden Field

For each hidden field:

  1. Click it in the editor to open its settings
  2. Under the General tab in Field Settings, give it a label (e.g., “Attribution Channel”). This label only shows up in the Gravity Forms admin — it won’t affect how AttributionHub finds the field.

The General tab with the Field Label setting

  1. Switch to the Advanced tab in Field Settings
  2. In the Default Value field, type the AttributionHub field name wrapped in square brackets — for example, [ah_lt_channel]. The brackets are important! Use the exact name from the Field Reference.

This Default Value is how AttributionHub knows which piece of data goes where.

The Advanced tab with the Default Value field

Make sure the name inside the brackets exactly matches one of the supported field names below.

Important: Leave the “Allow field to be populated dynamically” checkbox unchecked. AttributionHub writes values directly into hidden fields in the DOM, and enabling dynamic population can interfere with that — fields may end up empty or overwritten.

Step 4: Save and Test

  1. Hit the Save Form button in the top right corner of the editor
  2. Open a page on your site that has the form
  3. Submit a test entry and check that attribution values show up in the entry details inside WordPress admin

For a full walkthrough, see Verify It Works.

Here are the most commonly used fields for Gravity Forms. For the complete list, see Field Reference.

Core Attribution Fields (Latest Touch)

These capture 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 source that brought a visitor to your site. Once set, they never change:

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 more fields — latest-non-direct touch (ah_lnd_*), drill-down fields, raw UTM parameters, ad click IDs — see the full Field Reference.

Custom Field Mapping

Already have fields with different names (say, from a CRM integration)? You can remap AttributionHub’s output to match using fieldMapping:

<script> window.attrhub = { settings: { fieldMapping: { "latest.attribution.channelGroup": "lead_channel", "latest.attribution.source": "lead_source", "latest.attribution.campaign": "campaign_name", }, }, }; </script>

With this in place, AttributionHub fills 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 finds and populates every form on the page independently.
  • Multi-page forms — Put hidden fields on the first page so they get filled as soon as the form loads.
  • Conditional logic — Hidden fields work fine with Gravity Forms conditional logic. You can show or hide other fields based on attribution values if you want.
  • Confirmations and notifications — Attribution values are part of the entry data, so you can reference them in confirmation messages, email notifications, or feed add-ons (CRM integrations, etc.).
  • Pre-existing entries — Fields are only populated at submission time. Older entries won’t be updated retroactively.

Troubleshooting

Checking that fields are populated

A quick way to verify everything is working: open your browser’s DevTools (F12), go to the Elements tab, and look for hidden <input> elements inside the form. You should see your AttributionHub field names with values filled in.

DevTools showing hidden input fields populated with attribution values

Hidden fields are empty in form entries

  1. Make sure the AttributionHub script is actually loading — check the Network tab in DevTools for the script request
  2. Double-check that the Default Value on each hidden field exactly matches a supported field name, including the square brackets (e.g., [ah_lt_channel])
  3. Confirm “Allow field to be populated dynamically” is not checked
  4. Turn on logging (enableLogging: true in your settings) and look at the browser Console for population messages

Fields show “[object Object]” or unexpected values

This usually means the Default Value doesn’t match a valid field name. Check the spelling and brackets against the Field Reference.

Form loads after the script runs

This is rare with Gravity Forms since it renders inline, but it can happen if the form loads via AJAX or inside a modal. AttributionHub’s MutationObserver should catch it automatically. If it doesn’t, see the Form Integrations troubleshooting guide for more options.