How to create Redirect Codes?

Redirect codes are a unique feature in Terminus that allow you to attach any piece of Javascript to your short urls.

Additionally, you can extract UTM and other data from your URLs and inject them into your javascript. It allows you to do things like:

  • Create a very customizable retargeting and remarketing campaigns and show people ads based on which campaign they were part of
  • Track PDF file downloads in Google Analytics or any other analytics service
  • Send short URL click event to your Google Analytics in real time
  • Send people to any third-party website and still be able to track those clicks.

Here's a quick video that goes through this feature:


1. Go to Tools > Redirect Codes

Navigate to Tools > Redirect Codes in your project.

2. Create a new redirect code

Click Create a New Redirect Code

Enter the details:

  1. Specify a Name that will be used to show in the dropdowns when building URLs
  2. Type or paste the javascript. It should be a valid HTML that wraps your code in <script> and </script> tags.
  3. (Optional) Select Always apply to make this a default when building URLs.

When writing your Javascript code, you'll be able to use Terminus dynamic tags that can be inserted in your code. Here's an example of what that looks like:

Example dynamic codes. Some of these will be different based on your own configuraiton

3. Use redirect codes when building URLs

Once the redirect codes are created, they'll be available when building URLs.

NOTE: The redirect codes are only available when using Terminus shortener. They cannot be used when using third-party shorteners like Bitly.

3. Some examples

To give you some ideas on how to use the redirect code feature, here are some examples.

NOTE: These examples are not guaranteed to work since the underlying services like Facebook, Google, etc. can change their interfaces.

a. Facebook retargeting

<!-- Facebook Pixel Code -->

<script>

!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?

n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;

n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;

t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,

document,'script','https://connect.facebook.net/en_US/fbevents.js');


fbq('init', 12345');

var fbTrack = function() {

fbq('track', "ShortUrlRedirect", {campaign: _tu.utm.campaign.tag})

}

setTimeout(fbTrack, 1000);


</script>


<noscript><img height="1" width="1" style="display:none"

src="https://www.facebook.com/tr?id=12345&ev=PageView&noscript=1"

/></noscript>

<!-- End Facebook Pixel Code -->

b. Track PDF file downloads in Google Analytics

<script>

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');


ga('create', 'UA-12345678-1', 'auto');


ga('set', 'campaignName', _tu.utm.campaign.tag);

ga('set', 'campaignMedium', _tu.utm.medium.tag);

ga('set', 'campaignSource', _tu.utm.source.tag);

ga('set', 'campaignContent', _tu.utm.content.tag);

ga('set', 'campaignKeyword', _tu.utm.term.tag);

ga('set', 'page', _tu.url);

ga('set', 'title', 'File Download');

ga('send', 'event', 'Download', 'File download', _tu.url);

ga('send', 'pageview', {'sessionControl': 'start'});

</script>

c. Track short URL clicks in Google Analytics in real time

<!-- Google Analytics -->

<script>

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');


ga('create', 'UA-12345678-1', 'auto');

ga('send', 'event', 'Short Url', 'Visit', _tu.utm.campaign.tag);

</script>

<!-- End Google Analytics -->

Still need help? Contact Us Contact Us