Purchase event fired before purchase is complete

Created on 29 March 2024, 9 months ago
Updated 11 September 2024, 3 months ago

Problem/Motivation

A purchase event is queued on commerce_order.place.pre-transition, but commerce_order.place.post-transition would be a better guarantee that order placement succeeded.

I classify this as Priority=MAJOR because customers will make ad spending decisions based on ROI signals from this purchase event, so it seems necessary to only fire it when we have maximum confidence that a valuable transaction completed successfully.

Aside: charges that seem to succeed initially can later fail (eg: via Stripe webhooks that inform you of failure after initial order processing). Facebook doesn't have an obvious way to cancel a previous purchase event, and this module doesn't try to send an offsetting negative-valued event. I do not attempt to solve that issue here.

Proposed resolution

I considered two alternatives:

  1. POST-TRANSITION. Enqueue purchase event on commerce_order.place.post-transition. This is appealing because of the limited modification to existing code and because no additional user configuration is required. A drawback is that it would enqueue an event for unattended purchases (eg: subscription renewals by commerce_recurring) which never hit a browser, and where these queued events will never be sent to FB.
  2. CHECKOUT COMPLETE PANE. Provide a pane for the "complete" step in the checkout flow, akin to the FacebookCheckout pane already provided by this module, but which would enqueue a Purchase event. Although this would give users a way to disable to purchase event by not placing the pane in a checkout flow, if the objective is to give users more fine-grained control when commerce events are sent to Facebook a more comprehensive approach would be a better fit.

In this issue I propose the first option, to handle the POST-TRANSITION event.

Remaining tasks

Implement and test!

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code (Facebook Pixel Commerce)

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024