August 13, 2010

Using bit.ly with Twitter’s Tweet Button

This afternoon, Twitter added its “Tweet Button” to the ranks of online content-sharing tools. Tech Crunch has been using the Tweet Button to share links with its custom bit.ly short domain tcrn.ch, and we wanted to pass along some tips for using bit.ly and the Tweet Button together.

Tech Crunch Using bit.ly Pro

Publishers can use their bit.ly short URLs with the Tweet Button the same way they have done with other sharing tools. Since bit.ly links never change or expire, a publisher will typically shorten long URLs on their back end and cache the corresponding bit.ly short URLs for repeated use. When the short URL for a given page is stored locally, it can easily be shared using the Tweet Button’s “url” parameter (and passing the page’s long URL in the “counturl” parameter to ensure that the Tweet count is correct) . For example, the following code creates a simple “Tweet” link for sharing this blog using its bit.ly short URL (http://bit.ly/2pqyWD):

<a href=”http://twitter.com/share?url=http%3A%2F%2Fbit.ly%2F2pqyWD&amp;counturl=http%3A%2F%2Fblog.bit.ly%2F”>
Tweet</a>

You can also use the “url” parameter to send a bit.ly short link to the Javascript Tweet Button:

<script src=”http://platform.twitter.com/widgets.js” type=”text/javascript”></script>

<div>

  <a href=”http://twitter.com/share?url=http%3A%2F%2Fbit.ly%2F2pqyWD&amp;counturl=http%3A%2F%2Fblog.bit.ly%2F” class=”twitter-share-button”>Tweet</a>

</div>

… and to the Tweet Button IFrame widget:

<iframe allowtransparency=”true” frameborder=”0” scrolling=”no” src=”http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fbit.ly%2F2pqyWD&amp;counturl=http%3A%2F%2Fblog.bit.ly%2F” 
style=”width:130px; height:50px;”></iframe>

Note that in all of these cases, the URLs being passed must be URL encoded.

We are working on some additional tools and resources for integrating bit.ly and the Tweet Button, and we look forward to sharing these with you soon!

mattlemay posted on August 13, 2010 | Permalink | Comments (View) | Share with bitly Sidebar
blog comments powered by Disqus