BlogGuides · October 23, 2026 · 5 min read

Contact Form 7 Form IDs: Match Shortcode Hashes, Post IDs and Event Filters

Distinguish CF7 shortcode hashes, numeric form records and HTML instance IDs before repairing event filters or migrating forms.

Geometric hash tile connected to a record cylinder and two form cards.
Conceptual illustration; not a product screenshot or measured result.

A Contact Form 7 shortcode can contain an alphanumeric ID while an event filter expects a number. Both can refer to the same form. The problem begins when a tracking rule, migration script or CSS selector treats those identifiers as interchangeable. Before replacing anything, identify the layer that consumes the value and record the actual mapping.

This guide focuses on identity mismatches. For general embedding, use the CF7 block and shortcode guide; for transporting configuration, use the export and import procedure. An identity audit is a useful step in both workflows, not a reason to rebuild working forms.

Recognize the different identifiers

CF7 introduced hash-based form identification in version 5.8 to improve portability of embedding blocks and shortcodes. Its release announcement explicitly retained the earlier post-ID-based approach. An older numeric shortcode is therefore not automatically broken simply because the form editor now displays a hash.

The form is also a WordPress record with a numeric post ID. The current CF7 frontend initializes its internal numeric identity from the generated hidden _wpcf7 field. DOM event details carry a contactFormId. Separately, an instance has a unitTag, and the page holding it can have a containerPostId. These fields answer different questions: which form definition, which rendered instance and which containing post.

Value Purpose Check before using it
Shortcode hash Resolve an embedded form Copy from the intended form editor
Numeric form post ID Identify the WordPress form record Match editor record and rendered form
Unit tag Distinguish a rendered instance Inspect the current page; do not assume permanence
HTML ID or class Target page elements Confirm uniqueness and actual markup
Container post ID Identify the containing post context Do not confuse it with the form record

Create a small identity map

Open the intended form in the WordPress editor. Record its title, the shortcode copied from that editor and the numeric record ID from the editor URL’s post parameter. Then open a page that embeds it and inspect the generated hidden form identity. Do this for each distinct form involved in your report, including similar forms with identical titles.

A useful audit row contains the site/environment, form title, shortcode identifier, numeric record ID, page URL and affected integration rule. Keep staging and production in separate rows. If a copied form has been recreated rather than transferred, it is a new record even when its fields and title look identical. Never infer the correct identity from a screenshot of the form alone.

Do not edit hidden fields to force a match. They describe what CF7 rendered; changing them in the browser is not a migration. Likewise, the hash is an identifier, not a password or authorization token. Access control and validation must remain server-side.

Inspect identifiers without printing answers

The following original diagnostic is intended for a controlled staging page. It listens for the documented CF7 submission event and prints only identity fields. It sends no analytics request and does not initiate a submission. Register it once, then run a permitted staging case:

document.addEventListener('wpcf7submit', (event) => {
  const detail = event.detail || {};
  console.table({
    formRecord: String(detail.contactFormId ?? ''),
    formInstance: String(detail.unitTag ?? ''),
    containingPost: String(detail.containerPostId ?? '')
  });
});

Compare the observed formRecord with the identity map. Do not copy detail.inputs into a shared console capture or analytics debugger: it can contain personal answers. The guide describes a procedure, not a test performed against your installation.

Repair the consuming rule

If a GA4 tag or custom handler compares contactFormId with the shortcode’s hash, replace that comparison with the verified numeric form-record value in the representation expected by the rule. Normalize types deliberately. For example, an application can compare String(event.detail.contactFormId) with its recorded ID string rather than relying on accidental numeric coercion. Keep the event’s meaning separate from the identity correction.

For a success measurement, use the appropriate success outcome rather than upgrading every wpcf7submit event into a conversion. Follow the event selection guide and GA4/GTM setup for that boundary. Changing the ID filter cannot turn invalid or spam attempts into qualified leads.

If a CSS rule is wrong, inspect the HTML ID or class it actually targets. Do not paste a form post ID into a selector and assume the matching element exists. A reusable class can style a form family; a unique HTML ID can target a specific instance. Those decisions belong to presentation, not the database lookup mechanism.

Recheck the map after a migration

On the destination, inspect the imported form and the page that embeds it. Verify the field list, recipient configuration and expected title before accepting a match. Check custom code, tag-manager variables, reporting labels and connector mappings that store numeric IDs. A portable embedding mechanism does not promise that every external numeric reference survives a move.

When two instances use the same form definition on one page, their form-record identity can match while their instance tags differ. Use the current instance context when a behavior should affect only one dialog or section. Read multiple forms on one page before using a document-wide selector. Do not hard-code an observed unit tag as a permanent cross-site business identifier.

Close the audit with outcomes, not just matches

Verify a nonmatching form does not trigger the rule, the intended form triggers it once, and a failed validation remains distinguishable from success. Preserve the before/after mapping and the date. If a report appears empty after the repair, confirm its date range and collection timing rather than assuming historical events have been relabeled.

Our free Svetlik Analytics for Contact Form 7 plugin is an option for form submission statistics. This is our product’s website. Keep its reporting identity aligned with your inventory; it does not automatically repair unrelated tag-manager filters or establish inbox delivery.

Sources