• Resolved bbaros77

    (@bbaros77)


    Hi,

    I have to set dynamic conversion value for google ads,I want to do it without a plugin, I just need the code to get order total. For now I have set the same value for every order(conversion),I put this code in my function.php and it worksite is tracking conversions :

    add_action( 'woocommerce_thankyou', 'bbloomer_conversion_tracking_thank_you_page' );
     
    function bbloomer_conversion_tracking_thank_you_page() {
       ?>
    <!-- Event snippet for Kupnja dizajniraj majicu conversion page -->
       <script type="text/javascript">
       gtag('event', 'conversion', {
        'send_to': 'AW-975759864/-8vzCNae5aHGOIHfrdED',
        'value': 10.0,
        'currency': 'HRK',
        'transaction_id': ''
    });
       </script>
       <?php
    }

    Some help would be much appreciated, should I use code like this,I found it on a woo-commerce site `

    function my_custom_tracking( $order_id ) {

    // Lets grab the order
    $order = wc_get_order( $order_id );
    }`

    and this goes in value <?php echo $order->get_total();?>

    I could not get it to work.

    Kind regards

    Boris

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Function.php Dynamic Conversion Value Code’ is closed to new replies.