Posts tagged with wordpress

I have a Wordpress page and I need to track all clicks as Google Ads conversion so I've found that I can use the entire page as a link with the following code:

<html>     <body onclick='window.location.href="http://google.com"'>     </body> </html>

Then I need to activate the Google conversion tag at every click and the conversion script are:

<!-- Event snippet for Solicitar cotação conversion page In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. --> <script>function gtag_report_conversion(url) {   var callback = function () {     if (typeof(url) != 'undefined') {       window.location = url;     }   };   gtag('event', 'conversion', {       'send_to': 'AW-ID/AWID',       'event_callback': callback   });   return false; }</script>

Ok, so please, how can I make every click count as a conversion?

Thank you very much.

I have a registration page on WP; when the data is collected it automatically logs the person in to the site. At that point I'd like to fire the Adwords conversion script in PHP.

This is what I have at the moment but it doesn't seem to be working (obvs changed

// register the user using the WP function do_action('user_register', $user_id);              // google script for signup echo "<script>          gtag('event', 'conversion', {'send_to': 'AW-id_number'});     </script>"; 

Is there an obvious reason why this isn't working?

Thanks for any help here.

i need display multiple ads on one page with this code:

<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script> <div id="gpt-passback650x250"> <script> window.googletag = window.googletag || {cmd: []}; googletag.cmd.push(function() { googletag.defineSlot('/162717810/xxxxx/650x250', [650, 250], 'gpt-  passback650x250').addService(googletag.pubads()); googletag.enableServices(); googletag.display('gpt-passback650x250'); }); </script> </div> 

If i use this code twice or more on page, i get error: Exception in queued GPT command TypeError: Cannot read property 'addService' of null

Code must be same, customer want paste it to page via shortcode in cms. How to solve this? Thanks

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,