4

I've implemented a share-URL-popup for Twitter but I think sometimes text + URL will not fit in to the 140 allowed chars of Twitter:

"https://twitter.com/intent/tweet" +
"?text=" + encodeURIComponent("long text here") +
"&url="  + encodeURIComponent("http://www.somevery.org/long-url/here/i-mean-very-very-long/")

What I want is to use a permalink, a shorter URL, instead (which looks like this: http://somevery.org/aUI8dj) but I also want to keep track of number of shares.

I'm not a fan of Twitter but IIRC it already shorten URLs itself.

Is that right? if not, I'm asking if there's a way to specify the count-URL as it is possible with the tweet-button plugin something like that:

"https://twitter.com/intent/tweet" +
"?text="      + encodeURIComponent("long text here") +
"&url="       + encodeURIComponent("http://www.somevery.org/aUI8dj")
"&count-url=" + encodeURIComponent("http://www.somevery.org/long-url/here/i-mean-very-very-long/")

1 Answer 1

3
+100

Yes, you can. I already have implemented this on my blog with a combination of http://bitly.com/ and http://www.addthis.com/ and it's pretty much easier and you don't need create a bunch of line of code.

First, create and account on bitly.com and addthis.com.

Login in your AddThis account and connect it to your bitly account. Follow this instructions for this process: http://support.addthis.com/customer/portal/articles/381247-url-shortening#shortening-bitly.

Then add the AddThis code on you site. Mine looks like:

<script type="text/javascript">
var addthis_share = {
    url_transforms : {
        shorten: {
            twitter: 'bitly'
        }
    },
    templates : {
        twitter : "{{title}} {{url}} via @YOUR-TWITTER-NAME"
    }
};
</script>

And the code for the social buttons:

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style addthis_counter_style">
    <a class="addthis_button_google_plusone" g:plusone:size="tall"></a>
    <a class="addthis_button_tweet" tw:count="vertical"></a>
    <a class="addthis_button_facebook_like" fb:like:layout="box_count"></a>
</div>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=YOUR-ID"></script>
<!-- AddThis Button END -->

When I discovered this option I wasn't really positive with it, but now I like it, because I have the stats of clicks on bitly and share metrics on AddThis. And the most important It didn't took much time to integrate the whole feature.

Also this option is better if you are going to use a custom domain like I did. Because bitly provides you the feature to custom your personal link with your domain, so you don't need to develop or use another software, it's all on bitly.

Example:
My custom URL shorten domain: http://pedroventura.es/1aN9V0b. This URL goes to http://www.pedroventura.com/php/problemas-codificacion-web-configurar-codificacion-utf8-php-mysql-y-html/. And if you click on Tweet button It will show the URL shorten but it counts the regular URL.

2
  • 1
    I don't want to use addthis.com!
    – user12370
    Commented Aug 9, 2013 at 8:40
  • Then you can use your code but instead of count-url try counturl, without hyphen. Check twitter documentation dev.twitter.com/docs/tweet-button#using-shorturl. I think that simple error was the problem.
    – Pedro V
    Commented Aug 9, 2013 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.