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.

Tag:google-ads-api, javascript, wordpress, jquery

3 comments.

  1. Snuffy

    Your google snippet should be placed between your <head></head> tag. In your child theme or active theme edit your header.php file where you should find the <head> tag. I pref to add any snippet before wp_head() function. Here is an example of header.php

    <!doctype html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <!-- 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> <?php wp_head(); ?> </head> <body <?php body_class(); ?>>

    Read more about how to adapt global site tag for your Google Ads account here

    1. Tiago Rossi

      Hello Martin, thank you for you input. I already have the global tag into the head, that way you said every time the page opens will trigger a conversion but I need to activate it only when a click happen.

    2. Snuffy

      Click on what? Just go create click event. Add this click event to element you want to track eg buttons , links , images. Here is more info about click triggers and other events support.google.com/tagmanager/answer/7679320?hl=en .

Add a new comment.