Skip to content

WooCommerce Enhanced Conversions duplicate country code in phone numbers #11737

@hussain-t

Description

@hussain-t

Bug Description

When WooCommerce purchases include a phone number that already contains a country code prefix (e.g., +94), Site Kit's Enhanced Conversions implementation adds the country code again programmatically, resulting in a duplicated prefix in the data layer.

Example:

  • User enters: +94771770589
  • Data layer outputs: +9494771770589 (country code +94 duplicated)

Expected behavior:
If the user-entered phone number already contains a country code prefix, Site Kit should not prepend it again.

Bug Bashing Asana ticket for reference.

Steps to reproduce

Steps to reproduce

  1. Install and activate WooCommerce
  2. Enable Site Kit's Enhanced Conversions (ensure gtagUserData feature flag is enabled)
  3. Create a test product in WooCommerce
  4. Proceed to checkout
  5. Enter billing information with a phone number that includes the country code, e.g., +94771770589
  6. Complete the purchase
  7. Inspect the data layer in Tag Assistant
  8. Observe the user_data.phone_number field shows a duplicated country code: +9494771770589

Additional Scenarios

Scenario 1: Short national number without country code

  • Input: 7800099
  • Expected: +447800099 (if billing country is UK)
  • Actual: Phone number doesn't appear in events (fails length validation after normalization)

Scenario 2: User enters a different country code than the billing country

  • Input: +2307800099 (Mauritius +230)
  • Billing Country: UK (which has +44)
  • Expected: +2307800099 (respect user's explicit country code)
  • Actual: +442307800099 (billing country code incorrectly prepended, overriding user's input)

Screenshots

Additional Context

  • PHP Version:
  • OS: [e.g. iOS]
  • Browser: [e.g. chrome, safari]
  • Plugin Version: [e.g. 22]
  • Device: [e.g. iPhone6]

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

Acceptance criteria

  • Phone numbers entered with a country code prefix (e.g., +94771770589) should not have the country code duplicated in the data layer.
  • Phone numbers entered without a country code prefix (national format) should have the billing country code prepended correctly.
  • Phone numbers entered with a different country code than the billing country should respect the user's explicitly provided country code.
  • All phone numbers should pass E.164 format validation (11-15 characters including +).

Implementation Brief

Test Coverage

QA Brief

Changelog entry

Metadata

Metadata

Assignees

Labels

P0High priorityTeam MIssues for Squad 2Type: BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions