Question

Can you set up link redirects?


Is it possible to set up link redirects? If you archive content, and a user clicks and old link to that content, can you make it so that they end up on a new page of your choice (either on inSided or not on inSided)


3 replies

Userlevel 5
Badge +4

Yes, we have 10-12 of these using third party scripts

<script> 
window.addEventListener('load', (event) => {
linkHandler("a[href='insided url goes here']", "redirect url goes here");


function linkHandler(selector, href) {
var link = document.querySelectorAll(selector);
link[0].href = href;
link[0].target = '_blank';
link[0].addEventListener('click', function (e) {console.log(link); e.stopPropagation() })
console.log(link);
return link;
}
</script>

 

You can do that linkHandler line multiple times with a ; after each. 

@SmartlyGreg as a third party scripts pro. 

And support should be able to help you clean things up. 

Badge

@DannyPancratz thats very kind of you!

I’ve recently done this myself because we were having trouble adding UTM tags to an SSO login link, and since we could not control the redirect URL after the SSO login was complete we decided to do it the other way around: Direct users to a tracked link which when detected by the script redirects the user to the SSO login page. 

It is very simple:

<script>
if (inSidedData.page.url.includes("UNIQUE PART OF URL TO REDIRECT")) {
window.location.replace("URL YOU WOULD LIKE THE USER TO LAND ON");
}
</script>

Now I’ve just tried this with an invalid URL and the error page flashes before the redirect but it works!

Badge +1

Note that if you are doing a lot of these (let’s say 50+), it might be better to reach out to inSided Professional Services who can do a server-side 301 redirect.

Advantages are:

  • Less custom javascript being evaluated on every page view
  • SEO will transfer over to the new page
  • Less error prone

Just send them an excel with two columns, old-url and new-url :)

Downsides are:

  • you are not fully in control yourself, so harder to do ad-hoc
  • costs a bit of money

Reply