A
A
Alexander Ivanov2016-02-03 20:24:15
Drupal
Alexander Ivanov, 2016-02-03 20:24:15

How to add metric in Drupal 7?

function hook_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'webform_client_form_111') {
    drupal_set_message('<pre>' . print_r($form,true) . '</pre>');
    $form['actions']['submit']['#attributes']['onclick'] = "yaCounter11111111.reachGoal('ORDER')";
  }
}

Tried to insert this code in template.php and in webform.api.php.
I tried to insert the id of the button into the attribute.
I took help here iamdroid.net/blog/yandex-metrika-counters .
function MYMODULE_form_alter
It is not clear from her article which MYMODULE should be written?
$form_id - determined correctly.
Drupal is not my habitat, where am I making a mistake?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ivanov, 2016-02-04
@cimonlebedev

Such an answer would be good, but apparently there are no experts.

function [название вашей темы]_form_[имя вашей формы]_alter(&$form, &$form_state) {
//drupal_set_message('<pre>' . print_r($form,true) . '</pre>');
  $form['actions']['submit']['#attributes']['onclick'] = "yaCounter3333333.reachGoal('ORDER')";
  $form['actions']['submit']['#attributes']['id'] = "lid1" ;
}
// в вашем случае webform_client_form_111
//имя формы берётся отсюда 
<input type="hidden" name="form_id" value="webform_client_form_110">

PS pfft...

A
Alexander Pupkin, 2016-02-03
@sakrab

Yandex.Metrica? =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question