How to implement Google Adwords conversion code in Contact Form 7 Wordpress

拟墨画扇 提交于 2019-12-12 18:23:46

问题


I want to integrate Google conversion Adwords code in Contact form 7 Plugin without redirecting to a ‘Thank You’ page.How to implement Google Adwords conversion code in Contact form 7 Plugin.Could someone help me.I would not prefer redirecting to another page.


回答1:


I found solution for implementing Google conversion Adwords code in Contact form 7.

Step 1 Edit the CF7 form you want to track conversions for and paste the Google Adwords Conversion code from google at the end of your form.

Step 2

Replacing on_sent_ok with DOM Events.

To replace it with an alternative code using DOM events, first, find the file named “functions.php” in the directory of your active theme. Second, add the following code at the bottom of the functions.php file:

add_action( 'wp_footer', 'mycustom_wp_footer' );

function mycustom_wp_footer() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
    typeof goog_report_conversion === 'function' && goog_report_conversion();
}, false );
</script>
<?php
}

Step 3

Remove the “on_sent_ok” line from the Additional Settings tab and save the contact form.



来源:https://stackoverflow.com/questions/47279181/how-to-implement-google-adwords-conversion-code-in-contact-form-7-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!