§32 埋点实战补充

add_action('woocommerce_payment_complete', 'send_tracking_data');
//add_action('woocommerce_after_checkout_billing_form', 'send_tracking_request');


function send_tracking_data($order_id) { 
     error_log('POSTHOG : send_tracking_data_order_id:'.$order_id); 
    $order = wc_get_order($order_id);
    $items = $order->get_items();
if ($this->tracking_method == "gtm") {
      add_action("wp_head", array($this->gtm, "begin_datalayer"));
      add_action("wp_enqueue_scripts", array($this->gtm, "enqueue_scripts"));
      add_action("wp_body_open", array($this->gtm, "add_gtm_no_script"));
    } else {
      add_action("wp_head", array($this, "enqueue_scripts"));
      add_action("wp_head", array($this, "ee_settings"));
    }
    add_action("wp_head", array($this, "add_google_site_verification_tag"), 1);