By Jens-1 on
Hello,
when links to articles are clicked, the browser automatically goes to the external URL. I would like Drupal to automatically replace all external links (where "external" can mean "other subdomain, other domain, or other root directory") with something like "http://$DRUPAL_SITE/exit.php?go=http://www.external-link.org", and then keep statistics on which external links people click on.
If there is no module like this already, how would I go about writing one? Basically it's a search&replace for new postings, and "search&replace back" if a post is edited.
Thanks!
Jens
Comments
This really would be nice
This really would be nice cause it would be nice to track links ( especially affiliate related ).
pretty easy...
This is not a module IMHO but a separate application closely coupled with Drupal. Name it exit.php, best place is the drupal install dir, include bootstrap.inc, issue a db_query to increase the counter and issue a header('Location ').
--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.
Yes, but this would need a
Yes, but this would need a filter for all Drupal content to *automatically* replace existing external links with links to exit.php?target=http://whatever. If I have lots of content and many editors I don't want to re-educate them all.
How would one implement this display filter in Drupal?
Thanks!
MyBlogLog
Try out http://www.mybloglog.com until something better is found.
MyBlogLog is all about tracking which of your blog's outgoing links are making readers click; in the simplest, most non-intrusive way possible..
Regards,
Czar
Two approaches
The weblink module provides this functionality, but you need to enter every external link in it first.
Then from anywhere in the site you use [weblink:linkid] and it tracks how many times the link is clicked.
The other approach is to write filter module that replaces every external link by prefixing it with a linktrack. For example instead of:
<a href="http://example.com/somepage.html">link description</a>with
<a href="/linktrack/http://example.com/somepage.html">link description</a>You would also need to have a database table that keeps track of these. For example, for an aggregate view, just have the URL, and number of clicks, ...etc. Or you can get sophisticated and store the URL, timestamp of the click, the ip address of the click, the referring page, ..etc.
You can check how the weblink module does, specifically the _weblink_filter_process() function.
--
Consulting: 2bits.com
Personal: Baheyeldin.com
--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba
Hi, The weblink module
Hi,
The weblink module would require two steps for every link, right?
1. enter it into the text as a [weblink:id] link,
2. enter it into the weblink config
Would it be possible to make the weblink module auto-create IDs for all external references, as soon as an article is saved? Then all I'd need is edit and save all stories once (this could maybe be scripted as well, just call the save hook for each article).
Thanks!
Yes, it is two steps
Yes, weblink requires two steps, one adding the link in web link, and two adding the weblink linkid to the node you are editing.
It may be better in your case to write a filter which automatically changes external links so that outgoing clicks on external links gets logged to a database table, as outlined above.
--
Consulting: 2bits.com
Personal: Baheyeldin.com
--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba
Writing a filter to replace URLs
Hi,
how would I go about writing such a filter? (I.e. what modules do I need to plug into, where would the filter go, etc)?
Would the replacement be "hard" (ie. would you see the edited URLs when later editing the article/story/.. again, or would it get changed back to the original URLs)?
Thanks!
Jens
I patched the URLfilter module to do this
I'm not sure if it's 100% correct, and I can't seem to paste PHP code into this form, so I'll try to append it to the urlfilter module's page: http://drupal.org/node/25252
How do yours go directly to external site?
I lost that when I upgraded to 4.6. Any url created with weblinks or flexinode content, link to the internal drupal page first, then you have to click the link. I am using taxonomy-dhtml & flexinode to create a menu of documentation links, but it annoys my users that they have to click on "Document XYZ" thinking they will go there, and instead get the drupal node page and have to click again.
Why not give a choice?
To turn on or off tracking? Im totally stumped as to how to get my links I have created NOT to go to the Drupal node. Though tracking may be important to many people, there are no doubt many of us who don't need this feature.