Skip to content

Conversation

chc421
Copy link
Contributor

@chc421 chc421 commented Sep 19, 2025

Description

Overview:
The CAPI Parambuilder library works with both client-side and server-side integration and can potentially improve fbc and fbp coverage and matchability.

In this PR, we are adding

  1. ParamBuilder client library (facebook-commerce-events-tracker.php)
  2. ParamBuilder server library (facebook-commerce-events-tracker.php)
  3. Enhance fbp missing for CAPI in initial events (Event.php)

Design doc: https://docs.google.com/document/d/1GH0dtJWjUrJlG8BUSzfyeoNlC9eK9-IdJBn3mp4shhM/edit?tab=t.0

Type of change

Please delete options that are not relevant

  • Add (non-breaking change which adds functionality)

Checklist

  • I have commented my code, particularly in hard-to-understand areas, if any.
  • I have confirmed that my changes do not introduce any new PHPCS warnings or errors.
  • I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors.
  • I followed general Pull Request best practices. Meta employees to follow this wiki.
  • I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes.
  • I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality.
  • I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this wiki.

Changelog entry

Add client and server parambuilder.

Test Plan

Manual test with following cases:

  1. Incognito mode: new visitor (no fbclick)
Screenshot 2025-09-30 at 2 47 57 PM Screenshot 2025-09-30 at 3 28 48 PM Screenshot 2025-09-30 at 3 31 00 PM
  1. Incognito mode: new visitor (with fbclick)
Screenshot 2025-09-30 at 2 57 50 PM Screenshot 2025-09-30 at 2 58 11 PM
  1. Admin page
Screenshot 2025-09-30 at 2 59 03 PM

Screenshots

Please provide screenshots or snapshots of the system/state both before and after implementing the changes, if appropriate

Before

Screenshot 2025-09-30 at 3 37 06 PM

After

Screenshot 2025-09-30 at 3 34 43 PM

D83659301

@meta-cla meta-cla bot added the CLA Signed label Sep 19, 2025
@chc421 chc421 marked this pull request as draft September 19, 2025 11:43
Copy link
Contributor

github-actions bot commented Sep 19, 2025

📦 Latest Plugin Build

Built at: 2025-10-06T17:02:35.261Z
Commit: c572757
Size: 1.4M

Download: Click here to download the plugin

To download: Click the link above → Scroll to bottom → Download "facebook-for-woocommerce" artifact

@chc421 chc421 added the changelog: add A new feature, function, or functionality was added. label Sep 23, 2025
@chc421 chc421 changed the title Pb fix 2 Pb fix option 3 Sep 26, 2025
@chc421 chc421 marked this pull request as ready for review September 30, 2025 19:39
@facebook-github-bot
Copy link
Contributor

@chc421 has imported this pull request. If you are a Meta employee, you can view this in D83659301.

*/
public function param_builder_server_setup() {
try {
$cookie_to_set = $this->get_param_builder()->getCookiesToSet();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_param_builder is a static method. It should be called with self:: and not $this.


wp_enqueue_script(
'facebook-capi-param-builder',
'https://capi-automation.s3.us-east-2.amazonaws.com/public/client_js/capiParamBuilder/clientParamBuilder.bundle.js',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that's gonna live forever ( long-term )?
Some users tend to dwell on a version for a long time. So if there's a chance that in future the team decides to shut this s3 down and replace it with another URL, that needs to be addressed now.
Either we need commitment from that team that they will inform us at least 6 months in advance, or we need to handle this ourselves

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hongj-src iirc this url should be a long term url?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This S3 link will be used for at least 6 months + usage. We are considering move to a CDN, but the task got delayed. Even our CDN is ready, we'll maintain both for certain period. We should be good use the s3 link

*
* @return string
*/
protected function get_browser_id() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do the same for fbc?
Was that skipped intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this. When I was testing, I found that it was already handled by https://github.com/facebook/facebook-for-woocommerce/blob/main/includes/Events/Event.php#L264. I don't think parambuilder would provide more than what is already there, but I can add the logic if there are cases that parambuilder can handle but the existing implementation cannot.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's add that since it's going to help improve the backend coverage

@chc421 chc421 requested a review from hongj-src October 3, 2025 13:40
Copy link

meta-codesync bot commented Oct 3, 2025

@chc421 has imported this pull request. If you are a Meta employee, you can view this in D83659301.

$this->aam_settings = $aam_settings;
$this->tracked_events = array();

$this->param_builder_server_setup();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this is not correct.
It should be self

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

param_builder_server_setup() is not a static method, do you want me to change its signature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added. CLA Signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants