问题
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 so there is no “landing page”.
We have read many posts and followed the guidance to use the Asynchronous AdWords Remarketing Tag
https://developers.google.com/adwords-remarketing-tag/asynchronous/
Therefore amending from this code:
<!-- Google Code for Footer Contact Form Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = XXXXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "XXXXXXXXXXXXXXXXXX";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/XXXXXXXXX/?label=XXXXXXXXXXXXXXXXXX&guid=ON&script=0"/>
</div>
</noscript>
To:
In head:
<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion_async.js" charset="utf-8"></script>
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");
}
});
}
});
However the client says the conversions are not registering even though the console log in registering correctly.
Any help would be much appreciated.
回答1:
The above solution is correct.
In the head, add:
<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion_async.js" charset="utf-8"></script>
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");
}
});
}
});
来源:https://stackoverflow.com/questions/46893217/google-adwords-conversion-on-ajax-form