Skip to Content

Ninja Forms

Ninja Forms is a flexible, free WordPress form builder with a drag-and-drop interface. It renders standard HTML <form> elements in the page DOM, so AttributionHub’s standard forms handler detects and populates it automatically.

Add hidden fields to your form with matching field names, and AttributionHub fills them with attribution data on every page load.

Prerequisites

Before you begin, make sure:

  • The AttributionHub tracking script is installed on your site (see Installation)
  • You have Ninja Forms 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 Ninja Forms > Dashboard
  2. Click on the form you want to edit, or create a new form

Step 2: Add Hidden Fields

  1. In the Ninja Forms builder, click the + Add new field button (or the + icon at the bottom of the form)
  2. In the field type list, find and click Hidden (under the “Layout & HTML” or “Miscellaneous” section, depending on your Ninja Forms version)
  3. Repeat this to add a hidden field for each attribution value 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 is for your reference only.
  3. Open the Administration tab (or Advanced settings)
  4. In the Field Key field, enter the AttributionHub field name (e.g., ah_lt_channel)

The Field Key is used as the HTML name attribute on the rendered hidden input. It must exactly match the field name in your AttributionHub field mapping.

Note: In some Ninja Forms versions, the name attribute follows a pattern like nf-field-XX. If you cannot change the field key to a custom value, you will need to use the fieldMapping setting to map AttributionHub paths to Ninja Forms’ field names. See Custom Field Mapping below.

Step 4: Save and Test

  1. Click Publish (or Save) to save your form
  2. Visit a page on your site that contains the form
  3. Open your browser’s DevTools (F12) and inspect the hidden <input> elements — check that they have attribution values
  4. Submit a test entry
  5. In WordPress admin, go to Ninja Forms > Submissions and find your test entry. The hidden field values should contain attribution data

For a full testing walkthrough, see Verify It Works.

The table below lists the most commonly used fields. For the complete field catalog, see Field Reference.

Core Attribution Fields (Latest Touch)

Field KeyDescriptionExample 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)

Field KeyDescriptionExample 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

Field KeyDescriptionExample 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 Ninja Forms uses auto-generated field names (like nf-field-1, nf-field-2), map AttributionHub’s internal paths to those names:

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

Replace the field numbers with the actual values from your form. You can find them by inspecting the rendered form in DevTools.

See Configuration for the full mapping reference.

Tips

  • Ninja Forms submissions — All submissions are stored in WordPress. Hidden field values appear in the submission details, making it easy to review attribution data per entry.
  • CRM integrations — If you use Ninja Forms’ CRM add-ons (Salesforce, HubSpot, Zoho CRM), map hidden fields to the corresponding CRM fields in the add-on settings.
  • Email notifications — Use merge tags like {field:ah_lt_channel} in your Ninja Forms email notification templates to include attribution values in emails.
  • Multi-page forms — Add hidden fields to the first page of your form for immediate population on load.
  • Zapier / webhook — The Ninja Forms Zapier or Webhooks add-on includes hidden field values in its payload. Connect it to any downstream tool for attribution tracking.
  • Conditional logic — Ninja Forms supports conditional logic. While rarely needed for hidden attribution fields, you can conditionally show fields based on attribution values.

Troubleshooting

Hidden fields are empty in submissions

  1. Inspect the rendered form in DevTools and check the name attributes on hidden inputs. Make sure they match your field mapping.
  2. If Ninja Forms uses auto-generated names (like nf-field-XX), configure fieldMapping to use those names.
  3. Enable logging (enableLogging: true in settings) and check the browser Console.

Form submission uses AJAX

Ninja Forms submits forms via AJAX by default. AttributionHub’s standard forms handler patches the submit event, and the attribution data is already set in hidden fields before submission occurs, so AJAX submissions work correctly.

Ninja Forms v2 vs v3

Ninja Forms v3 introduced a new form builder and changed field rendering. If you are on v2, the field names and structure may differ. Inspect the rendered HTML in DevTools to identify the correct field name attributes.