Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice: How to track outbound links?

How do you track outbound links for your web site, since the request is logged on the destination server, not yours?

like image 816
flamingLogos Avatar asked Oct 14 '08 01:10

flamingLogos


People also ask

How many outbound links should you include in each posting?

Try to include at least 4-5 internal links per external link in your posts.

Why is it important to be mindful of outbound follow links?

External Links and Backlinks As search engines rank you higher, more people visit your site, as more people visit your site, search engines then tend to rank you higher. Furthermore, when you include high-quality outbound links from other sites, you also encourage more backlinks.

How many outbound links is too many?

For user experience, under 15 – PLUS the minimum amount of outbound links to get the point across and cite the references, seems to correlate with our higher ranking content. That being said – i'd suggest at least 3 outbound links to high authority sites on every page, because it's only natural.


2 Answers

You can add a quick JQuery script to the page that will track external links and can either redirect them to a file on your server that will track the link and then forward to it, or add an ajax request that will submit on click for external links, and track them that way.

See:

  • http://www.prodevtips.com/2008/08/19/tracking-clicks-with-jquery-and-google-analytics/
  • https://web.archive.org/web/20090214024330/http://www.justskins.com/development/how-to-track-clicks-on-outgoing-links/132
like image 140
Eli Avatar answered Nov 05 '22 22:11

Eli


Method #1: target="_blank", onclick and Google Analytics Events

Format your outgoing links with the following attributes:

<a href="http://www.example.com" target="_blank" onclick="trackOutgoing(this);">outgoing</a>

Define a javascript tracking function (requires google analytics to be loaded already):

function trackOutgoing(el) {
  ga('send', 'event', {eventCategory: 'outbound',
                       eventAction: 'send',
                       eventLabel: el.getAttribute('href'),
                       eventValue: 1});
};

Pros:

  1. Does NOT interfere with normal link behavior
  2. Does NOT require redirecting to another url

Cons:

  1. The onclick is not guaranteed to execute (user or browser could terminate the main window)

Method #2: Redirecting with Javascript and Google Analytics Callbacks

Format your outgoing links with the following attributes:

<a href="http://www.example.com" onclick="trackOutgoingAndRedirect(this); return false;">outgoing</a>

Define a javascript tracking function (requires google analytics to be loaded already):

function trackOutgoingAndRedirect(el) {
  var url = el.getAttribute('href');
  ga('send', 'event', {eventCategory: 'outbound',
                       eventAction: 'send',
                       eventLabel: url,
                       eventValue: 1,
                       hitCallback: function() { document.location = url; }});
}

Pros:

  1. Does not require target="_blank"
  2. Higher chance of your event being registered with Google Analytics (compared to Method #1)

Cons:

  1. Overrides the default behavior of links with return false;
  2. Cannot open outgoing links in a new window

Method #3: Using a Redirect URL

Format your outgoing links with the following attributes:

<a href="/redirect?url=http://www.example.com">outgoing</a>

On your site you will need to implement a redirect script which is beyond the scope of this answer.

Your redirect script would most likely track the outgoing link and then redirect to the provided url.

Pros:

  1. No Javascript required
  2. Does NOT require Google Analytics
  3. Does NOT interfere with the normal link behavior

Cons:

  1. Harder to trigger Google Analytics Events
  2. Links do not link to their original URL. Which may have negative SEO implications.
like image 26
Justin Tanner Avatar answered Nov 05 '22 22:11

Justin Tanner