Hi Team!
I trying to install a google conversion tag in toolset form.
This script:
---------------
<!-- Event snippet for Conversão de Contacto 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) {
var callback = function () {
if (typeof(url) != 'undefined') {
window.location = url;
}
};
gtag('event', 'conversion', {
'send_to': 'AW-451504147/yYRiCP2pp_ABEJPQpdcC',
'event_callback': callback
});
return false;
}
</script>
---------------
I add script in HTML. How can i call gtag_report_conversion on form submit click?
According to the comment in the existing code, for this to work you just need to add a click event handler to the submit button which calls the function gtag_report_conversion.
You need a way to identify the form submit button (allowing for the possibility there could be other forms—and submit buttons—on the page). The easiest way to do that is to edit the form and add your own custom class to the submit button, e.g. "gtag-submit".
Then you can update your code to add that event listener. You can add the following to your existing code, just before the closing /script tag: