How to monitor clicks in Google ads- create a conversion

Introduction

What is a tag?

In Google analytics and the Google ads application, tags are snippets of code that are used to track user interactions. There is a master tag that calls a script to deal with any events. This tag is usually placed in the <head > tag of a web page. As the header is common to all pages on a site, this tag is global.

In the Google ads app, it is possible to set the tag manager to monitor for individual link clicks on a page. What follows is a step by step guide on how to do this .

Conversions, refers to any action a user makes that has a value to the site. For example a sale, a signup or a link click.

Step 1 – setup a conversion in Google ads

Click on tools and settings at the top of your Google ads application. Then click on conversions. You will see a list of existing conversions that you are monitoring.

click on conversions
An example link conversion

The bottom item is the one we will be creating. It listens for a click event on a link that then plays a YouTube video.

Step 2 – create a new conversion

Click on the “+” at the top of the conversions page to add a new conversion. Then click on website as the kind of conversion you want to create.

Click on “website”

Step 3 – setup the global site tag

If you are using Google analytics you may already have the global tag installed. If so, go to step 4.

Expand tag setup and click on install the tag yourself.

Click on install the tag yourself

The code

The global site tag is shown below this goes in the head section. For WordPress get the Plugin “insert headers and footers” and paste it there.

If you have a spare week or two here is a rather long tutorial on what window.datalayer is all about.

<!-- Global site tag (gtag.js) - Google Ads: 69250***** -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-692506****"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'AW-69250*****');
</script>

Once the global site tag is in place there are a couple of other things to do.

Step 4 – Add an onclick event handler.

To track clicks an onclick event handler needs to be added to the link. This calls the report conversion function and reports when the link has been clicked.

onclick=”return gtag_report_conversion(”https://youtu.be/QcSf7ZGEMyw);

<a href="https://youtu.be/QcSf7ZGEMyw" target="_blank" onclick="return gtag_report_conversion('https://youtu.be/QcSf7ZGEMyw');" rel="noopener noreferrer">
Using point motors to switch colour light signals - video</a>

Step 5 – add the gtag to the global site tag

To track links epatately the gtag tracker code has to be added to the global site tag in the header. Obtain it from the conversion details below.

Add the gtag tracker code to the header. The last line before the end script tag, below.

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-1214317****"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-1214317****');
  gtag('config', 'AW-692506***');
</script>

Step 5 – add the event handler to the page with the link.

The page that contains the tracked link needs the code below, get it from the conversion details. Add this at the top of the page. In WordPress at it to a custom HTML block in the Gutenberg editor.

<!-- Event snippet for Play you tube video - point motors 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-69250****/-_S8CKP5sbUBEKee****',
      'event_callback': callback
  });
  return false;
}
</script>

Finally , there can be a 24 hour lag before the tracking data shows up in the conversion listings. If the code is working, it will say No recent conversions. if it stays at unverified check your code for typos.

Leave a Reply

Your email address will not be published. Required fields are marked *