Reputation: 598
I want to integrate Google conversion code in Contact form 7 Plugin. I have setup everything. but getting error when form submits.
Uncaught ReferenceError: ga is not defined
at eval (eval at <anonymous> (scripts.js?ver=4.8:256), <anonymous>:1:1)
at String.<anonymous> (scripts.js?ver=4.8:256)
at Function.each (jquery.min.js:2)
at ajaxSuccess (scripts.js?ver=4.8:256)
at Object.<anonymous> (scripts.js?ver=4.8:324)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)
Contact form 7 A Additional Settings are as below
Upvotes: 0
Views: 674
Reputation: 1
on_sent_ok
and on_submit
are deprecated and scheduled to be abolished by the end of 2017.
You can use DOM
-events instead of these settings.
You can use this function
<script type="text/javascript">
document.addEventListener('wpcf7mailsent', function( event ) {
var img = document.createElement("img");
var goalId = "868xxxxxx"; // Your Google Conversion ID
var randomNum = new Date().getMilliseconds();
var value = 0;
var label = "WoZxxxxxxxxxx"; // Your Google Conversion Label
var url = encodeURI(location.href);
var trackUrl = "http://www.googleadservices.com/pagead/conversion/"+goalId+"/?random="+randomNum+"&value="+value+"&label="+label+"&guid=ON&script=0&url="+url;
img.src = trackUrl;
document.body.appendChild(img);
}, false );
</script>
Upvotes: 0
Reputation:
Replace Additional Settings with on_sent_ok: "typeof goog_report_conversion === 'function' && goog_report_conversion();"
and Put Google Adword Conversion code at the bottom of form as it is.
Upvotes: 2