diff --git a/handlers/views_handler_field.inc b/handlers/views_handler_field.inc
index 65210d9..ac02338 100644
--- a/handlers/views_handler_field.inc
+++ b/handlers/views_handler_field.inc
@@ -411,6 +411,7 @@ class views_handler_field extends views_handler {
         'prefix' => array('default' => '', 'translatable' => TRUE),
         'suffix' => array('default' => '', 'translatable' => TRUE),
         'target' => array('default' => ''),
+        'onclick' => array('default' => ''),
         'nl2br' => array('default' => FALSE, 'bool' => TRUE),
         'max_length' => array('default' => ''),
         'word_boundary' => array('default' => TRUE, 'bool' => TRUE),
@@ -722,7 +723,7 @@ class views_handler_field extends views_handler {
         '#dependency' => array(
           'edit-options-alter-make-link' => array(1),
         ),
-       '#options' => array(
+        '#options' => array(
           'none' => t('No transform'),
           'upper' => t('Upper case'),
           'lower' => t('Lower case'),
@@ -786,6 +787,16 @@ class views_handler_field extends views_handler {
         ),
       );
 
+      $form['alter']['onclick'] = array(
+        '#title' => t('onClick Event (javascript)'),
+        '#type' => 'textfield',
+        '#default_value' => $this->options['alter']['onclick'],
+        '#description' => t("To allow for custom link tracking with piwik"),
+        '#dependency' => array(
+          'edit-options-alter-make-link' => array(1),
+        ),
+      );
+
 
       // Get a list of the available fields and arguments for token replacement.
       $options = array();
@@ -1189,7 +1200,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent
 
     if (!empty($alter['make_link']) && !empty($alter['path'])) {
       if (!isset($tokens)) {
-       $tokens = $this->get_render_tokens($alter);
+        $tokens = $this->get_render_tokens($alter);
       }
       $value = $this->render_as_link($alter, $value, $tokens);
     }
@@ -1325,6 +1336,11 @@ If you would like to have the characters \'[\' and \']\' please use the html ent
       $options['attributes']['target'] = $target;
     }
 
+    $onclick = (trim(strtr($alter['onclick'],$tokens)));
+    if (!empty($onclick)) {
+      $options['attributes']['onclick'] = $onclick;
+    }
+
     // Allow the addition of arbitrary attributes to links. Additional attributes
     // currently can only be altered in preprocessors and not within the UI.
     if (isset($alter['link_attributes']) && is_array($alter['link_attributes'])) {
@@ -1464,13 +1480,13 @@ If you would like to have the characters \'[\' and \']\' please use the html ent
 
     foreach ($array as $param => $val) {
       if (is_array($val)) {
-         // Copy parent_keys array, so we don't afect other elements of this iteration.
-         $child_parent_keys = $parent_keys;
-         $child_parent_keys[] = $param;
-         // Get the child tokens.
-         $child_tokens = $this->get_token_values_recursive($val, $child_parent_keys);
-         // Add them to the current tokens array.
-         $tokens += $child_tokens;
+        // Copy parent_keys array, so we don't afect other elements of this iteration.
+        $child_parent_keys = $parent_keys;
+        $child_parent_keys[] = $param;
+        // Get the child tokens.
+        $child_tokens = $this->get_token_values_recursive($val, $child_parent_keys);
+        // Add them to the current tokens array.
+        $tokens += $child_tokens;
       }
       else {
         // Create a token key based on array element structure.
