フォーム送信フィールドでのユーザーのクリックスルーを追跡するためのカスタム スクリプトを設定する必要があります。これは私がこれまでに得たものです。ユーザーがフォーム フィールドを下に移動すると、カウンター変数 (ベース) は、ユーザーがパスに沿って到達した距離を合計します。基本変数を送信して、ユーザーがページを離れたときに結果を送信したいと考えています。jQueryで.unload関数を使おうと思っています。しかし、何らかの理由で、アンロードが私が思うように応答していません。何か案は?
var base = 0; //declares a variable of 0. This should refresh when a new user lands on the form page.
function checkPath(fieldNo, path) { //this function should check the current base value of the base variable vs the current fieldNo
if (fieldNo >= path) { //checks to see if base if lower than fieldNo
base = fieldNo; //if true, base is set to current fieldNo
return base;
} else {
return base; //if false, simply returns base.
}
};
$('#order_customer_fields_forename').focus(function () { //when the form box is selected should run checkPath then alert result.
checkPath(1, base);
});
$('#order_customer_fields_surname').focus(function () {
checkPath(2, base);
});
$('#order_customer_fields_postcode').focus(function () {
checkPath(3, base);
});
$('#order_customer_fields_address1').focus(function () {
checkPath(4, base);
});
$('#order_customer_fields_address2').focus(function () {
checkPath(5, base);
});
$(window).unload(function () {
alert(base);
});