Google AdWords Conversion on AJAX Form?

前端 未结 1 747
北荒
北荒 2021-01-24 03:26

We have been asked by a client to add their AdWord Conversion tracking code to a landing page following the completion of an enquiry form, the problem is the form is AJAX based

1条回答
  •  半阙折子戏
    2021-01-24 04:06

    The above solution is correct.

    In the head, add:

    
    

    In the JS:

    $.ajax({
        type: 'POST',
        url: "/contactSend.php",
        data: postData,
        success: function(result) {
            // CONVERSION TRACKING START 
            window.google_trackConversion({
                google_conversion_id: XXXXXXXXX,
                google_conversion_language: "en",
                google_conversion_format: "3",
                google_conversion_color: "ffffff",
                google_conversion_label: "XXXXXXXXXXXXXXXXXX",
                google_remarketing_only: false,
                onload_callback : function() {
                    console.log("Conversion Sent Contact");
                }
            });
        }
    });
    

    0 讨论(0)
提交回复
热议问题