Improved Digg Integration Script

Many of you probably already have yellow “digg this” buttons on your websites. I’ve improved the standard “digg this” script, and now you can use the improved version on your own site.

Every time any user visits your site, including users that have never heard of digg, they see the big yellow box. I’ve improved the original “digg this” button so that it will only be visible to visitors to your site that are familiar with digg. That way for most of your traffic you can save screen space, not confuse non-digg users, and simplify your site. However, you’ll still be able to provide an easy-to-use digg button to your digg-savy visitors.

Here’s an example of the improved “digg this” button in action:

If you don’t see anything here, visit digg.com, return to this site, and then press Reload or Refresh. If you want to see for yourself that this button doesn’t display to non-digg users, bookmark this page, clear your browser history, close your browser, and then visit this page again.

How to use the button on your site
In order to use it on your site, simply include the following HTML code where you want the “digg this” button to appear:

You can customize the colors, style, and link, by following the configuration directions for the original Digg integration script.

How does this work?
The script only displays the “digg this” script if the user has already been to either digg.com or www.digg.com. It uses a method for browser history detection described by Henrik Gemal. I first read about this technique on Jeremiah Grossman’s blog.

The script tells if a user has visited digg.com by first creating an invisible link on the page to digg.com. It then reads in the color of the link. If the color of the link matches the color for already visited links, then the script knows that the user has already visited digg.com. Even if the user has configured non-standard colors for their links, CSS is used to set the color of the invisible links to a known value.

Compatibility
The script has been tested with Internet Explorer, FireFox, Opera, and Safari. If anyone tests it with any other browsers, please let me know if it works for you.

10 Responses to “Improved Digg Integration Script”

  1. Dave Parker Says:

    Cool, nice work.

  2. Jay Says:

    Nice one

  3. Mike Says:

    That’s very useful information. Digg is already very popular and expect to see more traffic to your site through digg.

  4. Drew Says:

    Thanks for the great feedback everyone! A reader tested the code with Opera and it works.

  5. Drew Says:

    A friend tested the script in Safari, and it seems to work.

  6. Matt Says:

    Clever, but the trouble is that Digg users are tech-saavy and much MORE likely than the average user to manage their histories closely and employ plugins which obfuscate them and clean them regularly. In other words, you’ll be excluding exactly the audience you’re trying to target, all just to avoid confusing the audience you’re not. Really fun experiment, I gotta say, but I can’t possibly recommend using it.

  7. Drew Says:

    Matt, that’s true. Many Digg users I know also mainly use RSS to keep up with what’s on Digg.

    One goal of the script is to allow people that would normally not clutter up their with site with a “Digg This” button to at least sometimes place a button on their posts. Likewise you could create similar buttons for all of the major social news sites. When a user visits your site, they would only see buttons for the social news services that they use.

  8. improved reddit button for your site - int2e blog Says:

    [...] to our earlier improved Digg button, we’ve also created a reddit button. The button will only display for users to your site that [...]

  9. Jeremiah Grossman Says:

    Digg buttons with smarts!…

    Andrew “Drew” Hintz put the CSS History Hack to good use. He made a JavaScript include that only shows the “Digg” button to users who have actually been to Digg.com….

  10. Improved Netscape Voting for Your Site - int2e blog Says:

    [...] like our earlier Digg and reddit buttons, we’ve also created a Netscape voting button. The button will only display [...]

Leave a Reply