Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Track phone clicks and Contact form 7 submissions
// add tracking for phone call clicks
function google_phone_clicks_and_contact_form() { ?>
<!-- phone call tracking for analytics -->
<script type="text/javascript">
jQuery(document).ready(function() {
if (typeof ga !== 'undefined') {
ga('send', 'event', 'Contact', 'Phone', 'Click');
<?php if (is_page(558)) : // if on the contact page. replace page id with id of contact page on website ?>
document.addEventListener( 'wpcf7mailsent', function( event ) {
ga('send', 'event', 'Contact Form', 'submit');
}, false );
<?php endif; ?>
// include in footer
add_action('wp_footer', 'google_phone_clicks_and_contact_form');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.