Skip to main content
added 56 characters in body
Source Link
LoicTheAztec
  • 256.7k
  • 25
  • 403
  • 451

I have a google ads tag that is tracking my purchase for a woocommerce website. But inside the dataLayer I don't get the value or ordernumber back. I put this code inside my function.php:

function thankyou_page_tracking_code() { if ( ! is_wc_endpoint_url( 'order-received' ) ) {   return;  } ?> <script> gtag('event', 'conversion', { 'send_to': 'Here i write my number', 'value': 0.0, 'currency': 'EUR', 'transaction_id': '' }); </script> <?php } add_action( 'wp_footer', 'thankyou_page_tracking_code' ); 

} add_action( 'wp_footer', 'thankyou_page_tracking_code' );

But I don't see anything inside my dataLayer. I

I do get an error that says (in dutch)  : 
Variabele is als onwaar geretourneerd vanwege een onbekende fout tijdens de uitvoering 
Total Ecommerce Items Value (price * quantity) 
(Which in english is:
Variable returned false due to an unknown error during execution 
Total Ecommerce Items Value (price * quantity))

I tried multiple things but something like this:

 function thankyou_page_tracking_code() { if ( ! is_wc_endpoint_url( 'order-received' ) ) { return; } // Haal de order ID op uit de URL $order_id = isset( $_GET['order-received'] ) ? $_GET['order-received'] : ''; // Haal de WooCommerce order op $order = wc_get_order( $order_id ); if ( ! $order ) { return; // Als de order niet bestaat, stop dan } // Haal de order totaal en valuta op $order_total = $order->get_total(); $currency = get_woocommerce_currency(); // Voeg de Google Ads tracking code toe met de juiste transaction_id, value en currency ?> <script> gtag('event', 'conversion', { 'send_to': 'here i write my number', 'value': <?php echo $order_total; ?>, 'currency': '<?php echo $currency; ?>', 'transaction_id': '<?php echo $order->get_id(); ?>' }); </script> <?php } add_action( 'wp_footer', 'thankyou_page_tracking_code' );` 

This makes the webshop not even go to purchase page. Anybody an idea?

I have a google ads tag that is tracking my purchase for a woocommerce website. But inside the dataLayer I don't get the value or ordernumber back. I put this code inside my function.php:

function thankyou_page_tracking_code() { if ( ! is_wc_endpoint_url( 'order-received' ) ) { return; } ?> <script> gtag('event', 'conversion', { 'send_to': 'Here i write my number', 'value': 0.0, 'currency': 'EUR', 'transaction_id': '' }); </script> <?php 

} add_action( 'wp_footer', 'thankyou_page_tracking_code' );

But I don't see anything inside my dataLayer. I do get an error that says (in dutch)  : Variabele is als onwaar geretourneerd vanwege een onbekende fout tijdens de uitvoering Total Ecommerce Items Value (price * quantity) (Variable returned false due to an unknown error during execution Total Ecommerce Items Value (price * quantity))

I tried multiple things but something like this:

 function thankyou_page_tracking_code() { if ( ! is_wc_endpoint_url( 'order-received' ) ) { return; } // Haal de order ID op uit de URL $order_id = isset( $_GET['order-received'] ) ? $_GET['order-received'] : ''; // Haal de WooCommerce order op $order = wc_get_order( $order_id ); if ( ! $order ) { return; // Als de order niet bestaat, stop dan } // Haal de order totaal en valuta op $order_total = $order->get_total(); $currency = get_woocommerce_currency(); // Voeg de Google Ads tracking code toe met de juiste transaction_id, value en currency ?> <script> gtag('event', 'conversion', { 'send_to': 'here i write my number', 'value': <?php echo $order_total; ?>, 'currency': '<?php echo $currency; ?>', 'transaction_id': '<?php echo $order->get_id(); ?>' }); </script> <?php } add_action( 'wp_footer', 'thankyou_page_tracking_code' );` 

This makes the webshop not even go to purchase page. Anybody an idea?

I have a google ads tag that is tracking my purchase for a woocommerce website. But inside the dataLayer I don't get the value or ordernumber back. I put this code inside my function.php:

function thankyou_page_tracking_code() { if ( ! is_wc_endpoint_url( 'order-received' ) ) {   return;  } ?> <script> gtag('event', 'conversion', { 'send_to': 'Here i write my number', 'value': 0.0, 'currency': 'EUR', 'transaction_id': '' }); </script> <?php } add_action( 'wp_footer', 'thankyou_page_tracking_code' ); 

But I don't see anything inside my dataLayer.

I do get an error that says (in dutch): 
Variabele is als onwaar geretourneerd vanwege een onbekende fout tijdens de uitvoering 
Total Ecommerce Items Value (price * quantity) 
Which in english is:
Variable returned false due to an unknown error during execution 
Total Ecommerce Items Value (price * quantity)

I tried multiple things but something like this:

function thankyou_page_tracking_code() { if ( ! is_wc_endpoint_url( 'order-received' ) ) { return; } // Haal de order ID op uit de URL $order_id = isset( $_GET['order-received'] ) ? $_GET['order-received'] : ''; // Haal de WooCommerce order op $order = wc_get_order( $order_id ); if ( ! $order ) { return; // Als de order niet bestaat, stop dan } // Haal de order totaal en valuta op $order_total = $order->get_total(); $currency = get_woocommerce_currency(); // Voeg de Google Ads tracking code toe met de juiste transaction_id, value en currency ?> <script> gtag('event', 'conversion', { 'send_to': 'here i write my number', 'value': <?php echo $order_total; ?>, 'currency': '<?php echo $currency; ?>', 'transaction_id': '<?php echo $order->get_id(); ?>' }); </script> <?php } add_action( 'wp_footer', 'thankyou_page_tracking_code' );` 

This makes the webshop not even go to purchase page. Anybody an idea?

Source Link

Setting up google ads purchase for woocommerce but I don's get the correct data back in the dataLayer

I have a google ads tag that is tracking my purchase for a woocommerce website. But inside the dataLayer I don't get the value or ordernumber back. I put this code inside my function.php:

function thankyou_page_tracking_code() { if ( ! is_wc_endpoint_url( 'order-received' ) ) { return; } ?> <script> gtag('event', 'conversion', { 'send_to': 'Here i write my number', 'value': 0.0, 'currency': 'EUR', 'transaction_id': '' }); </script> <?php 

} add_action( 'wp_footer', 'thankyou_page_tracking_code' );

But I don't see anything inside my dataLayer. I do get an error that says (in dutch) : Variabele is als onwaar geretourneerd vanwege een onbekende fout tijdens de uitvoering Total Ecommerce Items Value (price * quantity) (Variable returned false due to an unknown error during execution Total Ecommerce Items Value (price * quantity))

I tried multiple things but something like this:

 function thankyou_page_tracking_code() { if ( ! is_wc_endpoint_url( 'order-received' ) ) { return; } // Haal de order ID op uit de URL $order_id = isset( $_GET['order-received'] ) ? $_GET['order-received'] : ''; // Haal de WooCommerce order op $order = wc_get_order( $order_id ); if ( ! $order ) { return; // Als de order niet bestaat, stop dan } // Haal de order totaal en valuta op $order_total = $order->get_total(); $currency = get_woocommerce_currency(); // Voeg de Google Ads tracking code toe met de juiste transaction_id, value en currency ?> <script> gtag('event', 'conversion', { 'send_to': 'here i write my number', 'value': <?php echo $order_total; ?>, 'currency': '<?php echo $currency; ?>', 'transaction_id': '<?php echo $order->get_id(); ?>' }); </script> <?php } add_action( 'wp_footer', 'thankyou_page_tracking_code' );` 

This makes the webshop not even go to purchase page. Anybody an idea?