Page 1 of 1

Yandex Metrika ReachGoal event

PostPosted: Tue Aug 20, 2019 9:13 am
by d0ublezer0
Hi!
Yandex.metrika uses reachgoal event for his analytic counter
my code form unlogged.tpl:
Code: Select all
<form action="<?php echo $action_url; ?>" method="post" name="adminForm" class="form-donotvalidate"
          novalidate="novalidate"
          onsubmit="ym(21517516, 'reachGoal', 'send-cart'); return true;">

"onsubmit" overwritted by OPC? i cant see this on real page.
Also, i want to catch click on submit button:
Code: Select all
<button <?= $disable_checkout ? "disabled" : "" ?>
                                        type="submit" <?php echo $op_onclick ?> class="btn" id="confirmbtn"
                                        onclick="ym(21517516, 'reachGoal', 'try-cart'); return true;">
                                    Confirm order
                                </button>


how to do this?

Re: Yandex Metrika ReachGoal event

PostPosted: Tue Aug 20, 2019 10:20 am
by d0ublezer0
I solved this problem by placing the JS code to an external file.

Re: Yandex Metrika ReachGoal event

PostPosted: Tue Aug 27, 2019 11:06 pm
by admin
hello, you can bind via jquery events as far as they don't override the opc's required events, or you can use opc's system to run your own code at form submit:

you can add this to your tabcontent.js
Code: Select all
function yourTrackingFunction() {
//possible return values are:
// true -> OK to proced with submit
// false -> unblock submit button and stop submit
// -1 -> do not unblock submit button and stop submit

}

if (typeof addOpcTriggerer !== 'undefined') {
addOpcTriggerer('callSubmitFunct', 'yourTrackingFunction');
}


best regards, stan