I would like to see support for outgoing links added. I realize the amount of complexity involved in having to map all the outgoing links.

Is there a hook to intercept the link function? (it's l(), right?) I guess without that, this may not be possible.

Comments

budda’s picture

Use JQuery to parse through all the external links. I'm open to patch submissions to enable this.

brmassa’s picture

Assigned: Unassigned » brmassa
Status: Active » Needs review
StatusFileSize
new1.15 KB

Guys,

a created a javascript that does this and track downloads. its required jquery, so its only useful for drupal 5. The patch is over DRUPAL-5--1-dev
also, i used the standard way to add javascript files in Drupal: drupal_add_js. Google Analytics FAQ says that its recommended to add the code just before the </body> tag because, on slow connections, the content should come before then a "counter". no technical issue involved.

regards,

massa

brmassa’s picture

StatusFileSize
new844 bytes

and the javascript

budda’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Status: Needs review » Needs work

Thanks for the progress on this feature.
However the javascript code only appears to support three filetypes filetypes = "xls|pdf|doc";

Should these filetypes be selectable in the GA admin, or should the code just count any links which match a certain path maybe? Such as any files in sites/example.com/files/attachments/* ?

Either way, there needs to be a way to define what filetypes to track - what about people wanting to track download clicks of mp3s/podcasts, videos, or images?

brmassa’s picture

Mike,

you are completelly right! i just did a prototype. further improvements, like selecting what types of files, transforming segmentation in a drupal_add_js call and using http://dean.edwards.name/packer/ to compress the javascript can be also a plus.

regards,

massa

budda’s picture

What does "transforming segmentation in a drupal_add_js call" mean?

I don't understand what benefit the packing would have on such a small script? Especially if the script is cached once the browser has gotten it.

brmassa’s picture

Mike,

1* Drupal offers a standard way to put javascripts on pages: drupal_add_js. you can include javascript files or variables. The current code includes the Segmentation variable printing a script tag with the variable inside. it can be done using drupal standards

if (!empty($fields)) {drupal_add_js(array("utmSetVar"=> implode(":", $fields), "setting");}

2* javascript code can be compressed up to 75% using this tool. Once its cached, ok. but before this, it can save bandwidth. Since the code isnt big, there is no big deal, but its painless to help.

regards,

massa

brmassa’s picture

Status: Needs work » Needs review
StatusFileSize
new6.01 KB
brmassa’s picture

StatusFileSize
new789 bytes

the compressed javascript

brmassa’s picture

StatusFileSize
new6.01 KB

some bug fixes

brmassa’s picture

StatusFileSize
new6.2 KB

i discovered a more elegant way.

brmassa’s picture

StatusFileSize
new696 bytes

oips.. the js also improved

brmassa’s picture

Status: Needs review » Closed (duplicate)

Guys,

i did a series of tests and its working fine. i just some modifications and the final patch is on issue http://drupal.org/node/142514.

follow there all updates.

best regards,

massa