How to implement Google Adwords conversion code in

2019-07-19 15:58发布

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条回答
我想做一个坏孩纸
2楼-- · 2019-07-19 16:09

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.

查看更多
登录 后发表回答