Hi! I need to call a function onclick on a button.
Here is my code:
<div id="atendimento" class="tab_content">
<?= $this->Form->create(null, [
'url' => ['plugin' => 'contacts', 'controller' => 'PropertyContactRequest', 'action' => 'add'],
'data-ajax-submit',
'data-form-reset',
]) ?>
And here is the form

Here the google isntructions:
In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. →
deanoj
2
Just use some javascript embedded in the page, nothing to with cakephp here… its been a “while” since I did frontend dev, but something like:
document.getElementById("MySubmitButtonID").addEventListener('click', function ()
{
gtag_report_conversion();
});
if you want something fancier like preventing double clicks firing 2 events you will need to make use of google.
Also worth mentioning is google tag manager - been years since i looked at it but I thought it was pretty awesome for this kind of thing at the time.