I'm wondering what the different options are for tracking outbound traffic. If someone could point me to modules or other solutions, that would be awesome. It would be great if the solution allowed google analytics to "see" the clicks so that reporting could be integrated.

Why I need this
It would be great to know how much people are clicking on various outbound links, but my main purpose is because I have Buy Ticket links that take the user to an outside ticket vendor (Vendini). It would be really great to be able to track how many times each of the outgoing links were clicked and from where.

Making the process automatic for the administrator
Here are the needs for this proposal:

  • logging and redirection - we need a way to log the information about: (I would imagine this part already exists in some form)
    • outbound link
    • referring page
    • timestamp
  • input filter identifies outbound links
  • jQuery redirects outbound links to outbound link processor

If the module needs to be developed, I was thinking it would be possible to create a filter that automatically picks up all outbound links, and adds a class to the link identifying it as outbound. Then when a user clicks on one of these links, some form of JavaScript could intercept it and pass the user through a link counter which would invisibly pass the user to the requested url. Thickbox seems to intercept links using this method, so I assume it's something easy to do in jQuery. Note: To me, this just sounds like a simple, yet powerful approach to this problem but I'm not really familiar with the code for jQuery, nor with how to build a filter module that would identify the outbound links and add the class to the anchor.

Any thouhts?

Comments

pwolanin’s picture

Have the each link point to a callback defined by your module with the path and/or query-string elements defining the actual destination.

When the user clicks on the link, you can then save the information you want in a table in the DB, and use drupal_goto to redirect them to the real destination.

---
Work: BioRAFT

OpenChimp’s picture

I've never written module code for drupal before, but would love to dive in. You mention defining a callback - I assume you mean an address that would carry out whatever actions I define. Could you point me in a good direction to get started?

I also discovered the Links Package project http://drupal.org/project/links and will spend some time looking into how it works.

I would really love to have tracking data handled by google analytics as well as storing the data in the local database. The local copy allows better presentation of data to the users with link popularity weighting/sorting. The google analytics however would allow for marketing goal tracking and better analysis of which parts of the site are most successful.

Here's an update to this posting that I made in the Links Package issues: http://drupal.org/node/146956

WCA’s picture

Google has a way to track outbound links by adding code to the link tag itself. Refer to:

http://www.google.com/support/googleanalytics/bin/answer.py?answer=55527...

However, this method will not work with the existing Analytics module because Google requires that the Analytics tracking code (the script tag) come before the links being tracked. If you look at the page source Drupal generates with the Analytics module installed and activated, you'll note that the tracking code is placed at the end of the page, just before the </body> tag.

It would be great to have an option in the Analytics module that would allow the user to specify if the tracking code should be placed at the top or bottom of the generated page code.

...dtw

Berto’s picture

Thanks WCA! I found this post trying to track some of my outgoing links. The latest version of Google Analytics does let you put it in the Header scope, so this solution is very nice. I'll be testing it and post if there's a problem.

- Berto
-- PricePlow.com - http://www.PricePlow.com
--- Price Comparisons for Supplements, Vitamins, and diet products

Yura Filimonov’s picture

There's a module called Click Thru Tracking
http://drupal.org/project/click

It tracks inbound links to your nodes from newsletters, emails and ads.

What I like here is that the module tracks real visits, not just of those visitors with Javascript enabled and when the Google Analytics loaded. Especially, when Google Analytics only allows you to track 4 conversions per one code. You have to create a duplicate profile for the same domain to track 4 more goals (read here).

A good outbound click tracking module should:
- track clicks within Drupal
- disregard search engine spiders (there are databases of search engine crawler IPs available for exclusion)
- redirect through a folder (such as /go/) so that affiliate links can be excluded from crawling with robots.txt (another variant is to use /go.php and use meta="robots" content="noindex, nofollow")

Read more about masking affiliate links here.

P.S. Yeah, I know this is an old thread, but maybe it might help *someone* searching for it (as I have found this thread, when I was looking just for the solution to track outbound links within Drupal).

WeRockYourWeb.com’s picture

We're looking for the same functionality - simply tracking impressions and clicks on outbound links so we can get click-through ratios by given time frames. Currently to accomplish this we use Piwik analytics, the Drupal path_redirect module, and goal tracking in Piwik. The drawback is that we need to manually merge Excel output to calculate click-through %'s.

david.lukac’s picture

There is an option in GA module settings to enable

Track clicks on outbound links

(also downloads and mailto).

Steve Polito Design’s picture

This can be done using Google Analytics and the Google Analytics Module. However, by default this just groups all outbound link clicks as "Outbound links". Also (as far as I can tell), this doesn't tell you on what specific page the user clicked that particular link on.

Drupal's Link Click Count is a simple solution for tracking both internal and external link clicks. It also ensures that each link (internal or external) will be tracked individually. This means that if you have two nodes that reference the same link, you can see the link click counts for each link individually.

I wrote a detailed tutorial that explains how to do this.

BennyLitmus’s picture

With the GA module, you can build a custom GA report that filters on Event Category = Outbound link and you will get all outbound links that were ever clicked on your site.

Page dimension will tell you the source page. Custom variables are also available. So for example, if you put the node title into a custom variable, it'll be available in the GA report.

FWIW, I usually export the data from GA custom flat table reports into Excel and do my data analysis in there.