-
-
Save KravMaguy/68a95942f465436c42e1ecac0093189b to your computer and use it in GitHub Desktop.
gtag wordpress contact form 7 track form submission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en-US"> | |
<head> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-115893469-1"></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', 'UA-115893469-1'); | |
gtag('config', 'AW-783002502'); | |
</script> | |
<!-- Event snippet for Get a free Quote form submission conversion page | |
In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. --> | |
<script> | |
function gtag_report_conversion(url) { | |
console.log('contact form 7 submitted conversion'); | |
var callback = function () { | |
if (typeof(url) != 'undefined') { | |
window.location = url; | |
} | |
}; | |
gtag('event', 'conversion', { | |
'send_to': 'AW-783002502/3N1UCJmkmooCEIbXrvUC', | |
'event_callback': callback | |
}); | |
return false; | |
} | |
</script> | |
<script> | |
document.addEventListener( 'wpcf7mailsent', function( event ) { | |
//ga( 'send', 'event', 'Contact Form', 'submit' ); | |
gtag_report_conversion(); | |
}, false ); | |
</script> | |
<!-- Event snippet for mobile phone calls conversion page | |
In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. --> | |
<script> | |
function gtag_report_conversion_phone(url) { | |
console.log('phone call clicked conversion'); | |
var callback = function () { | |
if (typeof(url) != 'undefined') { | |
window.location = url; | |
} | |
}; | |
gtag('event', 'conversion', { | |
'send_to': 'AW-783002502/WWFeCKrghpICEIbXrvUC', | |
'event_callback': callback | |
}); | |
return false; | |
} | |
</script> | |
////the phone number appears in the header of the website it has a css class whenever someone clicks the phone | |
/// number this happens: gtag_report_conversion_phone() is called | |
<script> | |
jQuery('.phone_acquisition, #phone-header-menu-icon').on('click', function(){ | |
console.log('phone acquisition fired'); | |
gtag_report_conversion_phone(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment