Trigger Google conversion on some event

Trigger Google conversion on some event

Normally Google conversion code is added in header or footer of the “Thank you for your purchase” pages. A conversion is logged when someone lands on such thank you pages. But what if you want to notify Google about a conversion when a certain event is triggered like Sigup, Buy Now or Register button is clicked.

Below is the code that can be used to create event based Google conversion.

var google_conversion_id = 1234567890;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "";
var google_conversion_value = 0;

var conversionLabels = {
  'order-success': "conversoin_label_here"

function trackConversion(label) {
  google_conversion_label = conversionLabels[label];

  document.write = function(text) {

/* then somewhere in your ui code: */

Now you can call trackCoversion on any event to trigger Google Conversion.

Author: Tahir Yasin

Tahir is a Passionate Web Developer from Lahore, Pakistan and a guy with NEVER-STOP-LEARNING attitude who keeps an eye on emerging technologies and customer trends.

3 thoughts on “Trigger Google conversion on some event”

Leave a Reply

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