How to Add Automatic Google URL Shortener on a Blogger Blog?

This service does not work.

Many of us are looking for automatic Google URL shortener “//goo.gl”. When I was reading many articles and tutorials about URL shortener, I found a solution by Mr MS-Potilas. Using the Google app engine he has created a smart way to use Google URL shortener. As a base, I am taking his code and app engine and presenting a URL shortener which includes URL short by “//goo.gl”, “//mcaf.ee” and “//cli.gs”. MS-Potilas URL shortener is a little different and does not include McAfee and Cligs URL shortener. It is not very tough to use this feature/script with the Blogger platform.

Default Google URL Shortener interface on //goo.gl home page

Google url shortener

Google URL shortener on your Blogger blogs with two other services
Custom Google URL Shortener

Install automatic URL shortener with //goo.gl

1. Blogger Dashboard › Select a blog › Switch to Template tab › Edit HTML › Expand widget templates
2. Now search for <data:post.body>
3. And now paste the following just below this or somewhere near ‘post-footer-line-3’ at right place.

Automatic URL shortener with http://goo.gl

<script type='text/javascript'>
    // Shorten Blogger post URLs using urltinyfy javascript API, by MS-potilas 2012
    // Updated new shortener by Vinay Prajapati, TechPrevue Labs 2013
    //<![CDATA[
    function loadscript(filename) {
      var scr=document.createElement('script');
      scr.setAttribute("type","text/javascript");
      scr.setAttribute("src",filename);
      document.getElementsByTagName("head")[0].appendChild(scr);
    }
    var waitElm=null;
    function urltinyfyprompt_callback(response) {
      if(waitElm) waitElm.style.display="none";
      var txt="Short URL";
      if(response.title && response.title!="") txt+=' for "'+response.title+'"';
      else if(response.longurl && response.longurl!="") txt+=" for "+response.longurl;
      if(response.tinyurl && response.tinyurl!="")
        prompt(txt+":", response.tinyurl);
      else
        alert("Could not get short URL, try again later." + ((response.error && response.error != "") ? ("nError: " + response.error) : ""));
    }
    function shortenUrl(elm, long_url, service) {
      waitElm=elm.parentNode.nextSibling;
      if(waitElm) waitElm.style.display="inline";
      loadscript("http://urltinyfy.appspot.com/"+service+"?unify=1&url="+encodeURIComponent(long_url) + "&callback=urltinyfyprompt_callback");
    }
    //]]>
    </script>
    <span class='shorturls'>Short URLs:
    <a expr:onclick='&quot;shortenUrl(this, &amp;#39;&quot; + data:post.url + &quot;&amp;#39;, &amp;#39;googl&amp;#39;);return false;&quot;' href='javascript:void(0)' title='Click to get short URL'>goo.gl</a>,
    <a expr:onclick='&quot;shortenUrl(this, &amp;#39;&quot; + data:post.url + &quot;&amp;#39;, &amp;#39;mcafee&amp;#39;);return false;&quot;' href='javascript:void(0)' title='Click to get short URL'>mcaf.ee</a>,
    <a expr:onclick='&quot;shortenUrl(this, &amp;#39;&quot; + data:post.url + &quot;&amp;#39;, &amp;#39;cligs&amp;#39;);return false;&quot;' href='javascript:void(0)' title='Click to get short URL'>cli.gs</a>
    </span><span style='display:none;'><img border='0' src='data:image/gif;base64,R0lGODlhEAALAPQAAP///wAAANra2tDQ0Orq6gYGBgAAAC4uLoKCgmBgYLq6uiIiIkpKSoqKimRkZL6+viYmJgQEBE5OTubm5tjY2PT09Dg4ONzc3PLy8ra2tqCgoMrKyu7u7gAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCwAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7AAAAAAAAAAAA'/></span><div style='clear:both'/>

4. Save the changes › Done.

How to generate //goo.gl short URL?

Just click on “//goo.gl” or “//mcaf.ee” or “//cli.gs” to generate respective short url for Blogger posts.

Goo.gl, Mcaf.ee, and Cli.gs shortener services are not available anymore.

Conclusion:

Url shortener is the best thing to fight with spam. It is a short and sweet way to distribute long URL over the internet especially on social media. Finally, a nice script is ready to create a short URL from “//goo.gl” that was most awaited by most of us.

17 thoughts on “How to Add Automatic Google URL Shortener on a Blogger Blog?”

  1. Avatar photo
    Himanshu Pandey

    Excellent. Waiting for long times. A good Holi gift. Wish you a colourful Holi.

  2. Avatar photo
    Sherry Sabatine

    Awesome..thanks for this. I have a blog full of images so this will come in very handy :)

    1. Avatar photo
      Vinay Prajapati

      Most welcome Sherry! Subscribe our blog for more awesome tips, gadgets and tricks… :)

  3. Avatar photo
    flood service

    Definitely, what a magnificent blog and informative posts, I will bookmark your site.Best Regards!

  4. Avatar photo
    Tech Notepad

    goo.gl will be shut down very soon…

    Now bit.ly is more popular…

    Could you please also provide that???

Comments are closed.

Scroll to Top