Skip to content

Optin Monster form tab with campaign name #13145

Description

@zutigrm

Feature Description

Originally submitted by Kelvin here - https://app.asana.com/1/8468971550303/project/1215795095553989/task/1216170547125582

For Optin monster, the campaign ID appears as the tab name: Form #jnpfwoygltxurnayflew

Shouldn't it be the campaign name instead? It might be more meaningful.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • When a Site Goals lead-generation breakdown tab represents an OptinMonster campaign, the tab should display the campaign's name instead of its ID (e.g. the campaign name rather than Form #jnpfwoygltxurnayflew).
  • When the campaign cannot be resolved (e.g. it no longer exists on the site), the existing ID-based fallback label continues to be shown.

Implementation Brief

  • Let non-numeric form IDs reach the resolver

    • create_request() drops any non-numeric ID before resolution, which is why OptinMonster campaign IDs never resolve
    • Add a branch for non-numeric string IDs rather than removing the conditional - the numeric check also protects the existing path from passing arbitrary strings to get_post_type()
    • Keep keying the result by the original requested value, as it does today
  • Add an OptinMonster resolution strategy in resolve_form_metadata()

    • For non-numeric IDs, resolve the campaign by slug against the omapi CPT:

      • get_page_by_path( $form_id, OBJECT, 'omapi' )
      • This is exactly what OptinMonster's own OMAPI::get_optin_by_slug() does
    • Use the post title as the form title

      • Scope the lookup to the omapi post type only
      • No hard dependency: If OptinMonster isn't installed the post type isn't registered and the lookup simply returns null, so the existing null > fallback path applies
    • Only call OptinMonster's own helper behind a class_exists check if you prefer using their API over a direct lookup

    • The current resolver only accepts publish, but OptinMonster stores a campaign as draft whenever its remote status isn't active, so a paused campaign with historical conversions would fall back to its ID

      • Accept draft for omapi specifically, so paused campaigns still show their name as well

Test Coverage

  • Extend tests/phpunit/integration/Modules/Analytics_4/Datapoints/Get_Form_MetadataTest.php: an omapi campaign resolves its title by slug; an unknown slug resolves to null so the fallback applies; a non-omapi post sharing the same slug is not disclosed; and a draft campaign case matching whichever status decision is taken above.
  • Extend the JS coverage in site-goals-breakdown / LeadGenerationPerformanceWidget tests with a non-numeric (string) form ID resolving to a title - today's cases only exercise numeric IDs.

QA Brief

Changelog entry

Metadata

Metadata

Assignees

Labels

P1Medium priorityTeam SIssues for Squad 1Type: BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions