Use code NOVASHARE for an extra 10% off!
  1. Home
  2. Docs
  3. General
  4. How to configure link shortening

How to configure link shortening

Link shortening can be a great way to ensure your links are not lengthy or distracting when people are sharing your content. This is especially true if you are using UTM parameters with Google Analytics. The following is not the prettiest URL.

https://domain.com/test-post/?utm_source=twitter&utm_medium=social&utm_campaign=novashare

After shortening the link it looks like this:

bit.ly/2VYEnEr

The shortened link will display when anyone shares something from your site. Here is an example below when sharing something to Twitter. Link shorteners also provide a lot of useful click data and reporting on your links in their dashboards.

Shortened Bitly URL example
Shortened Bitly URL example

There are a few networks where links aren’t shortened, as they don’t allow this. (LinkedIn, Pinterest, and Hacker News).

We offer multiple link-shortening options in Novashare. You can use Bitly, or use a custom option, which enables you to hook it up to any link shortener you want, such as Short.io, Rebrandly, PrettyLinks, GT Link Manager, YOURLS, BL.INK, TinyURL, and more.

Bitly

Bitly is a URL shortening service and link management platform that has been around since 2008. It works great with Novashare and only takes a few minutes to set up. Follow the steps below to enable Bitly link shortening.

Step 1

If you don’t already have an account with Bitly, sign up for an account at Bitly.com. Once you have an account, log into it as you will need to grab some information to complete the set up below.

Step 2

Click into the Novashare plugin settings.

Novashare plugin settings
Novashare plugin settings

Step 3

Click on the “Configuration” submenu.

Novashare configuration
Novashare configuration

Step 4

Scroll down to the “Link Shortening” section. Toggle on the “Enable Link Shortening” option. Bitly is the default Link Shortener that will be selected. This will generate Bitly short links for all share URLs.

Enable Link Shortening and Bitly
Enable Link Shortening and Bitly

Next, follow the steps below to generate your generic access token.

Generic access token

Bitly uses an access token for authentication. Follow the steps below to generate one.

Step 1

In your Bitly account, click into “Settings” on the left-hand side and then into “API.”

Bitly API settings
Bitly API settings

Step 2

Enter your Bitly password and click on “Generic Token.”

Generate Bitly token
Generate Bitly token

Step 3

Copy your access token and make sure to keep this a secret. You can always generate a new one if you are afraid your token has been exposed.

Step 4

Back in the Novashare plugin under the “Link Shortening” section, paste in your Generic Access Token.

Novashare Generic Access Token
Novashare Generic Access Token

Step 5

Click “Save Changes” This will automatically populate the Group field. And that’s it! Your social share URLs will now automatically be shortened with Bitly.

Group

The group from your Bitly account used to generate and store short links. Non-enterprise users will only have one default group.

Custom link shortener

Our custom link shortener option enables you to hook it up to any link shortener you want, such as Short.io, Rebrandly, PrettyLinks, GT Link Manager, YOURLS, BL.INK, TinyURL, and more. Essentially, if they provide an API (a programmatic way to generate shortlinks), then you can probably utilize it with Novashare.

Follow the steps below to configure a custom link shortener.

Step 1

Click into the Novashare plugin settings.

Novashare plugin settings
Novashare plugin settings

Step 2

Click on the “Configuration” submenu.

Novashare configuration
Novashare configuration

Step 3

Scroll down to the “Link Shortening” section. Toggle on “Enable Link Shortening” and choose “Custom” for your Link Shortener.

Custom link shortener
Custom link shortener

Step 4

You will now need to utilize our novashare_short_link_url filter along with your link shortener’s API. See how to add PHP to your WordPress site.

The code will vary based on the documentation from your link shortener. Here is an example of code we used to hook up short.io with Novashare for link shortening.

add_filter('novashare_short_link_url', function($short_url, $long_url, $network) {

    $response = wp_remote_post('https://api.short.io/links', [
        'headers' => [
            'Authorization' => 'xxxxxxxxxx', // your short.io API key
            'Content-Type'  => 'application/json',
            'Accept'        => 'application/json',
        ],
        'body' => json_encode([
            'originalURL'     => $long_url,
            'domain'          => 'xxxxxx', // your short.io domain
            'allowDuplicates' => false,
        ]),
    ]);

    if(is_wp_error($response)) {
        return $short_url; // fall back to default on failure
    }

    $body = json_decode(wp_remote_retrieve_body($response), true);

    if (!empty($body['shortURL'])) {
        return $body['shortURL'];
    }

    return $short_url;

}, 10, 3);
Short links in short.io
Short links in short.io

We recommend utilizing AI if you have trouble hooking them up. Or, you can always reach out to us if you need help.

Whenever a post or page on your site is shared for the first time, a Bitly link for each enabled social network is automatically generated and stored in your WordPress site’s database. This Bitly link is attached to that post or page.

In some rare cases, you might need to purge your short links. Note: This permanently deletes all short links from your database. We don’t recommend doing this unless you absolutely have to.

Shortened links will automatically get regenerated once people share them again. Beware of your plan limitations with your link shortening service. You don’t want to purge too frequently otherwise you might hit your limit. Nothing will break, they would simply not get shortened automatically until your monthly quota resets.

Follow the steps below to purge short links on your WordPress site.

Step 1

Click into the Novashare plugin settings.

Novashare plugin settings
Novashare plugin settings

Step 2

Click on the “Configuration” submenu.

Novashare configuration
Novashare configuration

Step 3

Scroll down to the “Link Shortening” section. Click “Purge Short Links.”

Novashare purge short links
Novashare purge short links

Related Articles