Posts tagged with woocommerce

Wanting to track 'Add to Cart' clicks on a WooCommerce store & Google Ads tell me I need to call gtag_report_conversion when any 'Add to cart' button is clicked on the site.

Some buttons are a link <a href="... etc"> using class="add_to_cart_button" - see example page

While other buttons are a <button> tag using class="single_add_to_cart_button" - see example page

I see from Google's instructions that the structure for a link is:

<a onclick="return gtag_report_conversion('http://example.com/your-link');"href="http://example.com/your-link">Add To Cart</a>

And the structure for a <button> tag is:

<button onclick="return gtag_report_conversion('http://example.com/your-link')">Add To Cart</button>

How can I construct a function hook that will create the above link / button tag structure & would it be an action or filter hook? Also, is it possible to use the classes mentioned earlier to define which buttons on the site should be affected by this particular function. The documentation showing what action & filter hooks are available for WooCommerce is here.

First of all, thanks for any help I can get here. I am not a professional and now, unfortunately, after many hours I just can't get any further.

I run a Woocommerce webshop and have integrated GA4 and Google Adwords Conversion + Remarketing via Tag Manager. In preview mode all tags and data layers are loaded correctly. But the Goolge Ads Remarketing Tag and the Conversion Tag are marked red and loaded but not sent.

The Error Message in Tag Manager Browser Plugin: HTTP response code indicates tag failed to fire: Status 400:

Google Tag Assistant - Conversion failed to fire

The Code in GTM Preview Mode when Remarketing Tag is fired ( everythings looks good ):

GTM - Preview - Remarketing Values

If i open Dev Tool on my Browser i see that some google Scripts are red ( Url = googleads.g.doublecklick...... ):

Google ads url is blocked

Unfortunately no conversions are recorded in Adwords and the imported conversions from GA4 are also counted only to a small amount. With the old Analytics UA I had no problems and almost all the conversions were displayed in Adwords.

GTM is published and i have no Ad Blockers running.

Conversion ID and Label is checked

The Google Ads Campaigns are running

I turned off the GTM plugin for wordpress and tried a paid plugin for google ads conversion tracking. Unfortunately i have had the same error.

In addition, I turned of almost all plugins and tested whether anything blocks. Unfortunately without result.

If I change the conversion ID in the remarketing tag and add "AW-", the tag is no longer displayed as red. However, I can not change the conversion tag because only numbers are allowed:

Trying Conversion ID with "AW-" in Remarketing Tag

I'm realy a bit desperate and really grateful for any ideas!

I need to create a function on which will record the 'Total Order value' on my order confirmation page in woocommerce, the function will be be used by microsoft ads to record the value of order against what i have spent, anybody any experience of doing this?

The code provided by microsoft is:

window.uetq.push('event', '', {'revenue_value': Replace_with_Variable_Revenue_Function(), 'currency': 'Replace_with_Currency_Code'});

So i need to create a function called 'revenue_value' for example which will pass the total order value to the above code. Anybody point me the right direction.

I implemented a custom script in tankyou page in my woocommerce store to track google ads conversions. This is my implementation:

add_action( "woocommerce_thankyou", "pixel_analytics_conversion_track_script", 20 ); if ( ! function_exists( 'pixel_analytics_conversion_track_script' ) ) {     function pixel_analytics_conversion_track_script($order_id){         if ( $order_id > 0 ) {             $order = wc_get_order( $order_id );             if ( $order instanceof WC_Order ) {                 $order_id               = $order->get_id(); // order id                 $order_key              = $order->get_order_key(); // order key                 $order_total            = $order->get_total(); // order total                 $order_currency         = $order->get_currency(); // order currency                 $order_payment_method   = $order->get_payment_method(); // order payment method                 $order_shipping_country = $order->get_shipping_country(); // order shipping country                 $order_billing_country  = $order->get_billing_country(); // order billing country                 $order_status           = $order->get_status(); // order status                 ?>                 <script type="text/javascript">                     jQuery(document).ready(function( $ ){                         console.log('PURCHACE EVENT');                         /* Track conversion on facebook Pixel */                         fbq('track', 'Purchase',                         {                             value: <?php echo $order_total ?>,                             currency: "<?php echo $order_currency ?>"                         });                                              /* Track conversion on Google Ads */                         gtag('event', 'conversion',                          {                              'send_to': 'AW-693771414/0MhwCMa9rLYBEJa56MoC',                              'value': <?php echo $order_total ?>,                              'currency': "<?php echo $order_currency ?>",                              'transaction_id': "<?php echo $order_id ?>"                         });                     });                 </script>                 <?php             }         }     } } 

The code works very well but some data is not precise and I think that probably the code above duplicates conversion if user goes to thank you page twice. We have an order confirmation email that has a link to the thankyou page of woocommerce.

As you can see Im sending the transaction_id parameter, so my question:

If the user loads twice or N times the thank you page the conversion will appear dupplicated in Google ads even if you send the transaction_id parameter?

Has anyone put a Google ad conversion tag on a WooCommerce order confirmation page?

We have our website on Wordpress, use WooCommerce for our ordering and use a Divi Theme.

I tried doing this with one webmaster and we weren't able to get it to work. We tried putting the tag on the order confirmation page and couldn't get it to work.

Now, I have a new webmaster. I set up the conversion tag in Google ads and emailed it to her. She said she used a plug in to set it up on the page. She said she viewed the page, but I'm still seeing it labeled as inactive in Google ads.

Don't know why we're having such problems? What's the trick?

I'm not very familiar with Wordpress. Seems like this should be worked out or other people should also be having this problem.

PHP was suggested as a tag for this question, so I thought I would add it.

Thanks,