How To Brand Your Ain Url Shortener Alongside Javascript Inwards Blogger

In the past, nosotros induce got already shown you lot how you lot tin role bit.ly to generate brusque URLs automatically. However, neither Google shortener nor Bit.ly allows you lot to induce got your custom domain URL shortener.  Recently, 1 of our users asked us close how to build your ain URL shortener inward Blogger? Influenza A virus subtype H5N1 custom URL shortener volition permit you lot to practise your ain branded domain to redirect to dissimilar external pages every bit per your needs. Today inward this article, nosotros volition present you lot how to build your ain URL shortener amongst JavaScript inward Blogger.

How Custom URL Shortener Works?

We volition endure using a script to practise our ain URL shortening service. This script tin too endure termed every bit "Simple Redirects". Just similar WordPress, you lot practise links that volition redirect you lot to external pages or domains. Unlike Blogger Custom Redirects, which does non allows you lot to redirect to other domains, they exclusively redirects to internal pages of your blog.

Default URL: www.facebook.com/mybloggerlab
Custom Branded Short URL: www.mybloggerlab.com/go/fb

Take a await at the higher upwardly links to sympathise how this script volition work. If you lot volition acquire to www.mybloggerlab.com/go/fb it volition accept you lot to the Facebook page of MyBloggerLab. Similarly you lot tin practise unlimited brusque URLs as well as Redirects using this script.

How to Make Your Own URL Shortener amongst JavaScript:

To install URL Shortener script inward your Blogger site, delight follow the below instructions correctly:
  1. Go to Blogger >> Template >> Edit HTML.
  2. Now inward the template codes,  search for </head> tag as well as but higher upwardly it glue the next JavaScript code:
<script language='javascript'>

//MyBloggerLab URL Shorener

//<![CDATA[
var substitution = window.location.href.split("go/")[1].replace("/","")
var urls={
    'fb':'https://www.facebook.com/mybloggerlab',
    'gplus':"https://plus.google.com/+mybloggerlab",
    'twitter':"https://twitter.com/mybloggerlab",
}
if(key){
    if(urls[key]){
        window.location.href=urls[key]
    }else{
        document.write("'"+key+"' non flora :(");
    }
}
//]]>
</script>

Customization: 

Now to practise brusque URLs you lot tin elementary build changes to the higher upwardly code. For example, inward the higher upwardly code search for this:

'fb':'https://www.facebook.com/mybloggerlab',

In the higher upwardly code fb is the keyword as well as https://www.facebook.com/mybloggerlab is the targeted website or webpage. If nosotros translated the higher upwardly code it way that when you'll view www.mybloggerlab.com/go/fb  it volition accept you lot to https://www.facebook.com/mybloggerlab.

You tin add together to a greater extent than brusque URLs every bit well, for event if you lot desire to practise a brusque link for you lot Pinterest profile as well as thus the higher upwardly code volition await similar this:

<script language='javascript'>
//MyBloggerLab URL Shorener
//<![CDATA[
var substitution = window.location.href.split("go/")[1].replace("/","")
var urls={
    'fb':'https://www.facebook.com/mybloggerlab',
    'gplus':"https://plus.google.com/+mybloggerlab",
    'twitter':"https://twitter.com/mybloggerlab",
   
'pinterest':"https://twitter.com/mybloggerlab",
}
if(key){
    if(urls[key]){
        window.location.href=urls[key]
    }else{
        document.write("'"+key+"' non flora :(");
    }
}
//]]>
</script>

3. After customizing the script every bit per your needs, press the "Save Template" push clitoris on the tiptop of your screen.

We promise this tutorial has helped you lot inward learning how to build your ain URL shortener inward Blogger. Let us know what are you lot thoughts inward the comments below.

Comments