getting Started
Overview
The WooCommerce source combines WooCommerce's REST API and WebHook to achieve reliable order synchronization.
Required parameters
site URL | Customer website domain |
Consumer Key | API KEY |
Consumer Secret | API SECRET |
Source configuration & GTM tracking
1. Access the TTO CDP backend and install the WP for WooCommerce repository.
After successful installation, a webhook address for the source "POST HTTP Endpoint" will be automatically generated. The next step is to set it up in the Worpress backend!

2. Access the Worpress backend, create an API Key, and configure a webhook.
Backend menu: WooCommerce > Advanced > REST API > Add API Key
Configure the Consumer key and Consumer Secret in the CDP source settings.
Backend menu: WooCommerce > Advanced > Webhook > Add Webhook
Configure the source webhook address to the push endpoint and select the order update event.


3. Access the GTM backend and import the CDP tracking template.
GTM backend Admin > import container > import template
Modify the TTO CDP code > Replace with the client's own CDP JS code
Modify the hostname of the trigger in the TTO CDP code > PageView-init
Modify the push source location in the Purchase code.




IV. Code snippets Configuration
In the WooCommerce backend, select Code Snippets -> Add Snippet
Choose to add custom code, PHP Snippet
Add the following PHP code, save and enable it.
The code automatically saves logs, which can be viewed in the status.
add_action( 'woocommerce_checkout_update_order_meta', 'save_ttoaid_from_cookie_to_order_meta', 10, 2 ); function save_ttoaid_from_cookie_to_order_meta( $order_id, $data ) { $order = wc_get_order( $order_id ); if ( $order ) { sync_ttoaid_logic( $order ); } } add_action( 'woocommerce_store_api_checkout_update_order_from_request', 'save_ttoaid_from_cookie_to_store_api', 10, 2 ); function save_ttoaid_from_cookie_to_store_api( $order, $request ) { sync_ttoaid_logic( $order ); } /** * 核心公用逻辑*/ function sync_ttoaid_logic( $order ) { $logger = wc_get_logger(); $log_source = array( 'source' => 'cookie-monitor' ); $order_id = $order->get_id(); if ( ! empty( $_COOKIE['_ttoaid'] ) ) { $ttoaid = $_COOKIE['_ttoaid']; $order->update_meta_data( 'cdp_id', $ttoaid ); $order->save_meta_data(); $logger->debug( "订单#{$order_id} 已成功保存cdp_id: " . $ttoaid, $log_source ); } else { $logger->debug( "订单#{$order_id} 结账时未发现_ttoaid Cookie", $log_source ); } } 




