javascript - Google Conversion tracking success callback -


i calling google conversion tracking code on success of ajax call. have change window location on success of ajax , track conversion @ same time.

is there way receive callback of conversion tracking success, can change window location on tracking success?

my code looks :

tracking works when :

var oreq = getxmlhttprequest(); if (oreq != null) {     oreq.open("post", "http://www.example.com/index.php?r=user/create-mobile-user", true);     oreq.onreadystatechange = function handler() {         if (oreq.readystate == 4) {             if (oreq.status == 200) {                 window.google_trackconversion ({                     google_conversion_id: 946425313,                     google_conversion_language: "en",                     google_conversion_format: "3",                     google_conversion_color: "ffffff",                     google_conversion_label: "7p62cprgtl4q4zulwwm",                     google_remarketing_only: false                 });             }         }     } } 

doesn't work in below code :

var oreq = getxmlhttprequest(); if (oreq != null) {     oreq.open("post", "http://www.example.com/index.php?r=user/create-mobile-user", true);     oreq.onreadystatechange = function handler() {         if (oreq.readystate == 4) {             if (oreq.status == 200) {                 window.google_trackconversion ({                     google_conversion_id: 946425313,                     google_conversion_language: "en",                     google_conversion_format: "3",                     google_conversion_color: "ffffff",                     google_conversion_label: "7p62cprgtl4q4zulwwm",                     google_remarketing_only: false                 });                 window.location.href = "http://www.example.com/booking";             }         }     } } 

answering own question :

you can pass callback function in json given google_trackconversion function.

following working code :

 window.google_trackconversion({   google_conversion_id: 946425313,   google_conversion_language: "en",   google_conversion_format: "3",   google_conversion_color: "ffffff",   google_conversion_label: "7p62cprgtl4q4zulwwm",   google_remarketing_only: false,   onload_callback: function() {      window.location.href = "http://www.example.com/booking";   }  }); 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -