When an ajax call is successful, I am triggering the Google conversion tracking code. Along with tracking the conversion, I also need to change the window location.
Is there a method to receive a callback when the conversion tracking is successful, so that I can alter the window location upon successful tracking?
The current implementation of my code looks like this:
It works when I perform the following steps:
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
});
}
}
}
}
However, it does not work in the code snippet below:
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";
}
}
}
}