我在 ajax 调用成功时调用谷歌转换跟踪代码。我必须在 ajax 成功时更改窗口位置并同时跟踪转换。
有什么方法可以接收转化跟踪成功的回调,以便我可以更改跟踪成功的窗口位置?
我的代码看起来像:
当我这样做时跟踪工作:
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
});
}
}
}
}
在下面的代码中不起作用:
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";
}
}
}
}