diff --git a/readme.txt b/readme.txt index 7069e38..953dbbe 100644 --- a/readme.txt +++ b/readme.txt @@ -95,6 +95,7 @@ Release date: 2024-MM-DD Find out about what's new in our [our release post](https://gtmkit.com/gtm-kit-1-20/). #### Enhancements: +* Added support for the 'new_customer' parameter on the 'purchase' event, which is used for customer acquisition reporting and Google Smart Shopping campaigns. * Added a debug log for debugging the 'purchase' event without make a purchase. #### Bugfixes: diff --git a/src/Integration/WooCommerce.php b/src/Integration/WooCommerce.php index 7146748..fd6ae44 100644 --- a/src/Integration/WooCommerce.php +++ b/src/Integration/WooCommerce.php @@ -8,6 +8,7 @@ namespace TLA_Media\GTM_Kit\Integration; +use Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore; use Automattic\WooCommerce\StoreApi\StoreApi; use Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema; use Automattic\WooCommerce\StoreApi\Schemas\V1\CartItemSchema; @@ -561,14 +562,15 @@ public function get_purchase_event( WC_Order $order, array $data_layer = [] ): a $order_value -= $shipping_total; } - $data_layer['event'] = 'purchase'; - $data_layer['ecommerce'] = [ + $data_layer['event'] = 'purchase'; + $data_layer['ecommerce'] = [ 'transaction_id' => (string) $order->get_order_number(), 'value' => (float) $order_value, 'tax' => (float) $order->get_total_tax(), 'shipping' => (float) $shipping_total, 'currency' => $order->get_currency(), ]; + $data_layer['new_customer'] = ! DataStore::is_returning_customer( $order ); $coupons = $order->get_coupon_codes();