Skip to Content

WPForms

WPForms is a popular drag-and-drop WordPress form builder used by over 6 million websites. It renders standard HTML <form> elements in the page DOM, which means AttributionHub’s standard forms handler detects and populates it automatically — no dedicated handler or special configuration is needed.

All you need to do is add hidden fields to your form with the correct field 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 WPForms installed and activated in WordPress (Lite or paid version)
  • You have access to the WordPress admin panel to edit forms

Note: Hidden fields in WPForms require WPForms Pro, Plus, or higher. The free Lite version does not include the hidden field type. If you are on the Lite version, consider using a custom HTML field or a code snippet to add hidden inputs.

Step 1: Open Your Form

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

Step 2: Add Hidden Fields

  1. In the WPForms drag-and-drop builder, find the Fancy Fields section in the left panel
  2. Drag the Hidden Field element onto your form
  3. Repeat this for each attribution field you want to capture

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. Set the Label to something descriptive (e.g., “Attribution Channel - Latest”). This label is only used in the WPForms admin and does not affect how AttributionHub matches the field.
  3. In the Default Value area, leave it empty — AttributionHub will populate it automatically
  4. Expand the Advanced section
  5. In the CSS Classes field or Field Name field (depending on your WPForms version), find the field’s HTML name attribute. In WPForms, the name attribute follows a pattern like wpforms[fields][7] where 7 is the field ID

Important: Field Name Mapping

WPForms uses sequential numeric IDs for field names (e.g., wpforms[fields][7]). This means you need to use AttributionHub’s custom field mapping to connect the internal field paths to WPForms’ field names.

After adding your hidden fields, note the field ID for each one (visible in the form builder or by inspecting the HTML output). Then configure the field mapping:

<script> window.attrhub = { settings: { fieldMapping: { "latest.attribution.channelGroup": "wpforms[fields][7]", "latest.attribution.source": "wpforms[fields][8]", "latest.attribution.medium": "wpforms[fields][9]", "latest.attribution.campaign": "wpforms[fields][10]", "latest.attribution.landingPageUrl": "wpforms[fields][11]", "first.attribution.channelGroup": "wpforms[fields][12]", "first.attribution.source": "wpforms[fields][13]", visitorId: "wpforms[fields][14]", }, }, }; </script>

Replace the field IDs (7, 8, 9, etc.) with the actual IDs from your form.

Alternative approach: Some WPForms add-ons or custom code solutions allow you to set custom name attributes on hidden fields. If these are available, use standard names like ah_lt_channel to avoid the numeric mapping.

Step 4: Save and Test

  1. Save your form after adding and configuring all hidden fields
  2. Visit a page on your site that contains the form
  3. Open your browser’s DevTools (F12) and inspect the hidden <input> elements — they should have attribution values populated
  4. Submit a test form entry
  5. In WordPress admin, go to WPForms > Entries and click on your form. The test entry should show attribution values in the hidden fields

For a full testing walkthrough, see Verify It Works.

For the complete field catalog, see Field Reference.

Core Attribution Fields (Latest Touch)

DescriptionExample Values
Channel group (latest touch)Paid Search, Organic Social, Direct
Traffic source nameGoogle, Facebook, Direct
Traffic mediumpaid, organic, social, email
Campaign namespring_sale, Organic Search
Landing page URL (no query string)https://yoursite.com/pricing

Core Attribution Fields (First Touch)

DescriptionExample Values
Channel group (first touch)Paid Search, Organic Social
Traffic source nameGoogle, Facebook
Campaign namelaunch_campaign

Global Fields

DescriptionExample Values
Unique visitor ID, persistent across visitsa1b2c3d4-e5f6-7890-abcd-ef1234567890
Total number of recorded visits5

Tips

  • WPForms entries — All WPForms paid plans include an entries management system. Hidden field values appear alongside other field data in the entry details, making it easy to see attribution data for each submission.
  • Email notifications — Hidden field values are included in WPForms email notifications by default. You can use Smart Tags like {field_id="7"} to include specific attribution values in notification emails.
  • Conditional logic — WPForms supports conditional logic on fields. You can reference hidden field values in conditions, though for attribution fields this is rarely needed.
  • WPForms integrations — If you use WPForms integrations (Salesforce, HubSpot, Zapier, etc.), map the hidden fields to destination fields in the integration settings.
  • Multi-page forms — Add hidden fields to the first page of your multi-page form so they are populated as soon as the form loads.
  • Conversational Forms — WPForms’ Conversational Forms add-on works with hidden fields. The fields are populated in the background while the visitor sees the conversational interface.

Troubleshooting

Hidden fields are empty in entries

  1. Verify the field mapping in your AttributionHub settings matches the actual WPForms field IDs. Inspect the form in DevTools to find the correct name attributes.
  2. Confirm the hidden fields are inside the <form> element in the rendered HTML.
  3. Enable logging (enableLogging: true in settings) and check the browser Console.

Cannot find the hidden field type

The hidden field type requires WPForms Pro, Plus, or higher. If you are on the Lite version, you can add hidden fields using a code snippet in your theme’s functions.php or via the WPForms custom HTML field (if available).

Field IDs change after re-creating a form

If you delete and re-create a form, the field IDs will change. Update your fieldMapping configuration to match the new IDs.