Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This function is called when the customer completes the checkout process.
- * It takes the order ID as an argument and uses it to get the order total.
- * It then uses the order total to send a conversion tracking event to Google Analytics
- *
- * @param order_id The order ID.
- *
- * @return The order total.
- */
- add_action('woocommerce_thankyou', 'conversion_tracking_thank_you_page', 95, 1);
- function conversion_tracking_thank_you_page($order_id)
- {
- $order = wc_get_order($order_id);
- if (!$order_id)
- return;
- foreach ($order->get_items() as $item_id => $item) {
- $total = $item->get_subtotal_tax();
- }
- $product_gtag = '
- <script>
- gtag("event", "page_view", {
- "send_to": "AW-10852304507/GCDUCITa7aMDEPuM5LYo",
- "value": "' . $total . '",
- "currency": "PLN",
- "transaction_id": ""
- });
- </script>';
- echo $product_gtag;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement