Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track a Google Adwords conversion onclick?

Google Adwords offers no code to add to your page to count a conversion if somebody clicks on a link. But as it's Javascript, I am sure there is a way to do this.

Here's the code (unaltered) Google gives you to include in the page, that should count as a conversion (most of the time a thank you page):

<!-- Google Code for Klick Conversion Page --> <script type="text/javascript"> <!-- var google_conversion_id = 1062751462; var google_conversion_language = "de"; var google_conversion_format = "1"; var google_conversion_color = "ffffff"; var google_conversion_label = "dKXuCODvugEQ5pnh-gM"; var google_conversion_value = 0; //--> </script> <script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <div style="display:inline;"> <img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1062751462/?label=dKXuCODvugEQ5pnh-gM&amp;guid=ON&amp;script=0"/> </div> </noscript> 

With other conversion tracking scripts some function has to be executed to count the conversion. Here, just adding the JS-File to your page can be enough to trigger the conversion-tracking, as conversion.js calls a function on load (download it and look at it after running it through a code beatuifier, it's really quite nice work!).

Any idea how to tackle this?

like image 833
janpio Avatar asked Jan 17 '10 18:01

janpio


People also ask

How do I track Google conversion ads?

Just set up a different conversion action for each type of conversion you want to track. For example, you can set up one conversion action to track purchases on your website, and another to track calls from your ads. You can also set up multiple conversion actions for each conversion source.

How do I track ad clicks in Google Analytics?

Analyze ad impressions and clicks in Universal Analytics To analyze impressions or clicks in Google Analytics, switch to your account and go to Behavior > Events > Top Events. As soon as Google Analytics tracks ad impressions or clicks, you should see Advanced Ads in the Event Category list.

Does Google Ads automatically track conversions?

Also, app downloads and in-app purchases from Google Play, and local actions will automatically be recorded as conversions, and no tracking code is needed.


2 Answers

Don't know if you've already found it... I mention it anyway for future surfers...

I was looking for the same, and found this piece of code :

<script type="text/javascript">      function trackConv(google_conversion_id, google_conversion_label) {         var image = new Image(1, 1);          image.src = "//www.googleadservices.com/pagead/conversion/" + google_conversion_id + "/?label=" + google_conversion_label + "&script=0";       }  </script> 

Then for links which you want to track just do this :

<a onclick="trackConv(1234567890, 'LQV8CNq6RxCKlPbvAw');" href="http://www.example.com">Link</a>  
like image 52
Eli Avatar answered Sep 23 '22 07:09

Eli


It appears that Google now offers an onclick option that you can copy and paste from the Conversions page in AdWords. From the AdWords Conversions page:

Add the tag to a button on your website, such as a "Buy now" button.

Here's a snippet from the page of documentation entitled Track clicks on your website as conversions. Replace XXXXX with conversion ID and label:

<!-- Google Code for Conversion Page In your html page, add the snippet and call goog_report_conversion when someone clicks on the chosen link or button. --> <script type="text/javascript">   /* <![CDATA[ */   goog_snippet_vars = function() {     var w = window;     w.google_conversion_id = XXXXXXX;     w.google_conversion_label = "XXXXXXX";     w.google_remarketing_only = false;   }   // DO NOT CHANGE THE CODE BELOW.   goog_report_conversion = function(url) {     goog_snippet_vars();     window.google_conversion_format = "3";     var opt = new Object();     opt.onload_callback = function() {     if (typeof(url) != 'undefined') {       window.location = url;     }   }   var conv_handler = window['google_trackConversion'];   if (typeof(conv_handler) == 'function') {     conv_handler(opt);   } } /* ]]> */ </script> <script type="text/javascript"   src="//www.googleadservices.com/pagead/conversion_async.js"> </script> 

And somewhere else in your code

button.addEventListener('click', function() {   console.log('Button clicked!');   goog_report_conversion(); }); 
like image 37
Jonathan Guerrera Avatar answered Sep 21 '22 07:09

Jonathan Guerrera