Hi,

I haven't dug deep in your code, but the structure of the table fitted my needs. However, I wanted to track the clicks without having to use the API, so I added a few small things to do the job using JQuery.

I added the following to urlproxy.module:

  drupal_add_js(drupal_get_path('module', 'urlproxy') .'/urlproxy.js');

  /**
   * Record clicks using Javascript
   */
function urlproxy_js_click() {
  if ($_GET['url']) {
    global $user;
    urlproxy_add_hit('general', urldecode($_GET['url']), NULL, urldecode($_GET['referer']), 'urlproxy', array('type' => 'general', 'user' => $user));
  }
  exit;
}

And created the new file urlproxy.js with the following contents:

// Javascript Document

Drupal.behaviors.urlproxy = function(context) {
  $("a").click(
    function() {
      $.get('/proxy/click/?url=' + Drupal.encodeURIComponent(this.href) + '&referer=' + Drupal.encodeURIComponent(document.referrer), null, null);
    }
  );
}

This records all clicks on the site (if the client has javascript enabled)... Feel free to implement it in some way if you wish to. It could be selected as an optional tracking-method on a config page or something....

Cheers!

CommentFileSizeAuthor
urlproxy.js_.txt264 bytes2xe

Comments

2xe’s picture

Ah... and the menu:

  $items[URLPROXY_PATH . '/click'] = array(
     'title' => 'Recording Click',
     'page callback' => 'urlproxy_js_click',
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
  );  

And if you wish to skip the admin folder:

/**
 * Record clicks using Javascript
 */
function urlproxy_js_click() {
  if ($_GET['url']) {
    global $user;
    if (!preg_match('@\/admin@', $GET['url'])) {
      urlproxy_add_hit('general', urldecode($_GET['url']), NULL, urldecode($_GET['referer']), 'urlproxy', array('type' => 'general', 'user' => $user));
    }
  }
  exit;
}